Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix constraint reference params #23845

Merged
merged 1 commit into from
May 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions dev/breeze/src/airflow_breeze/commands/ci_image_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import click

from airflow_breeze.branch_defaults import DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
from airflow_breeze.commands.main_command import main
from airflow_breeze.params.build_ci_params import BuildCiParams
from airflow_breeze.params.shell_params import ShellParams
Expand All @@ -36,6 +35,7 @@
option_additional_runtime_apt_deps,
option_additional_runtime_apt_env,
option_airflow_constraints_mode_ci,
option_airflow_constraints_reference_build,
option_answer,
option_build_multiple_images,
option_debian_version,
Expand Down Expand Up @@ -221,12 +221,7 @@
@option_runtime_apt_deps
@option_force_build
@option_airflow_constraints_mode_ci
@click.option(
"--airflow-constraints-reference",
default=DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH,
help="Constraint reference to use when building the image.",
envvar='AIRFLOW_CONSTRAINTS_REFERENCE',
)
@option_airflow_constraints_reference_build
@option_tag_as_latest
def build_image(
verbose: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import click

from airflow_breeze.branch_defaults import DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
from airflow_breeze.commands.main_command import main
from airflow_breeze.global_constants import ALLOWED_INSTALLATION_METHODS, DEFAULT_EXTRAS
from airflow_breeze.params.build_prod_params import BuildProdParams
Expand All @@ -35,6 +34,7 @@
option_additional_runtime_apt_deps,
option_additional_runtime_apt_env,
option_airflow_constraints_mode_prod,
option_airflow_constraints_reference_build,
option_answer,
option_build_multiple_images,
option_debian_version,
Expand Down Expand Up @@ -249,12 +249,7 @@
'--install-airflow-reference',
help="Install Airflow using GitHub tag or branch.",
)
@click.option(
"--airflow-constraints-reference",
default=DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH,
help="Constraint reference to use when building the image.",
envvar='AIRFLOW_CONSTRAINTS_REFERENCE',
)
@option_airflow_constraints_reference_build
@click.option('-V', '--install-airflow-version', help="Install version of Airflow from PyPI.")
@option_additional_extras
@option_additional_dev_apt_deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from datetime import datetime
from typing import List, Optional

from airflow_breeze.branch_defaults import AIRFLOW_BRANCH, DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
from airflow_breeze.branch_defaults import AIRFLOW_BRANCH
from airflow_breeze.utils.console import get_console
from airflow_breeze.utils.platforms import get_real_platform

Expand All @@ -42,12 +42,10 @@ class _CommonBuildParams:
additional_runtime_apt_env: str = ""
airflow_branch: str = AIRFLOW_BRANCH
airflow_constraints_location: str = ""
airflow_constraints_reference: str = "constraints-main"
answer: Optional[str] = None
build_id: int = 0
constraints_github_repository: str = "apache/airflow"
debian_version: str = "bullseye"
default_constraints_branch = DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
dev_apt_command: str = ""
dev_apt_deps: str = ""
docker_cache: str = "registry"
Expand Down
5 changes: 5 additions & 0 deletions dev/breeze/src/airflow_breeze/params/build_ci_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from pathlib import Path
from typing import List

from airflow_breeze.branch_defaults import DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
from airflow_breeze.global_constants import get_airflow_version
from airflow_breeze.params._common_build_params import _CommonBuildParams
from airflow_breeze.utils.console import get_console
Expand All @@ -31,6 +32,7 @@ class BuildCiParams(_CommonBuildParams):
"""

airflow_constraints_mode: str = "constraints-source-providers"
airflow_constraints_reference: str = DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
airflow_extras: str = "devel_ci"
airflow_pre_cached_pip_packages: bool = True
force_build: bool = False
Expand All @@ -46,6 +48,9 @@ def image_type(self) -> str:
@property
def extra_docker_build_flags(self) -> List[str]:
extra_ci_flags = []
extra_ci_flags.extend(
["--build-arg", f"AIRFLOW_CONSTRAINTS_REFERENCE={self.airflow_constraints_reference}"]
)
if self.airflow_constraints_location is not None and len(self.airflow_constraints_location) > 0:
extra_ci_flags.extend(
["--build-arg", f"AIRFLOW_CONSTRAINTS_LOCATION={self.airflow_constraints_location}"]
Expand Down
21 changes: 9 additions & 12 deletions dev/breeze/src/airflow_breeze/params/build_prod_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class BuildProdParams(_CommonBuildParams):
"""

airflow_constraints_mode: str = "constraints"
airflow_constraints_reference: str = ""
airflow_is_in_context: bool = False
cleanup_context: bool = False
disable_airflow_repo_cache: bool = False
Expand Down Expand Up @@ -79,20 +80,16 @@ def args_for_remote_install(self) -> List:
"AIRFLOW_SOURCES_TO=/empty",
]
)
if len(self.airflow_constraints_reference) > 0:
if re.match('v?2.*', self.airflow_version):
build_args.extend(
["--build-arg", f"AIRFLOW_CONSTRAINTS_REFERENCE={self.airflow_constraints_reference}"]
["--build-arg", f"AIRFLOW_CONSTRAINTS_REFERENCE=constraints-{self.airflow_version}"]
)
else:
if re.match('v?2.*', self.airflow_version):
build_args.extend(
["--build-arg", f"AIRFLOW_CONSTRAINTS_REFERENCE=constraints-{self.airflow_version}"]
)
else:
build_args.extend(
["--build-arg", f"AIRFLOW_CONSTRAINTS_REFERENCE={self.default_constraints_branch}"]
)
if len(self.airflow_constraints_location) > 0:
build_args.extend(
["--build-arg", f"AIRFLOW_CONSTRAINTS_REFERENCE={self.airflow_constraints_reference}"]
)
if self.airflow_constraints_location:
# override location if specified
build_args.extend(
["--build-arg", f"AIRFLOW_CONSTRAINTS_LOCATION={self.airflow_constraints_location}"]
)
Expand Down Expand Up @@ -165,7 +162,7 @@ def extra_docker_build_flags(self) -> List[str]:
"--build-arg",
f"AIRFLOW_INSTALLATION_METHOD={self.installation_method}",
"--build-arg",
f"AIRFLOW_CONSTRAINTS_REFERENCE={self.default_constraints_branch}",
f"AIRFLOW_CONSTRAINTS_REFERENCE={self.airflow_constraints_reference}",
]
)

Expand Down
9 changes: 9 additions & 0 deletions dev/breeze/src/airflow_breeze/utils/common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import click

from airflow_breeze.branch_defaults import DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
from airflow_breeze.global_constants import (
ALLOWED_BACKENDS,
ALLOWED_BUILD_CACHE,
Expand Down Expand Up @@ -415,8 +416,16 @@
"--airflow-constraints-reference",
help="Constraint reference to use. Useful with --use-airflow-version parameter to specify "
"constraints for the installed version and to find newer dependencies",
default=DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH,
envvar='AIRFLOW_CONSTRAINTS_REFERENCE',
)
option_airflow_constraints_reference_build = click.option(
"--airflow-constraints-reference",
default=DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH,
help="Constraint reference to use when building the image.",
envvar='AIRFLOW_CONSTRAINTS_REFERENCE',
)

option_airflow_constraints_mode_ci = click.option(
'--airflow-constraints-mode',
type=BetterChoice(ALLOWED_CONSTRAINTS_MODES_CI),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# We handle the ImportError so that autocomplete works with just click installed
version = None # type: ignore[assignment]

from airflow_breeze.branch_defaults import AIRFLOW_BRANCH, DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH
from airflow_breeze.branch_defaults import AIRFLOW_BRANCH
from airflow_breeze.global_constants import (
ALLOWED_PACKAGE_FORMATS,
FLOWER_HOST_PORT,
Expand Down Expand Up @@ -456,7 +456,6 @@ def update_expected_environment_variables(env: Dict[str, str]) -> None:
:param env: environment variables to update with missing values if not set.
"""
set_value_to_default_if_not_set(env, 'AIRFLOW_CONSTRAINTS_MODE', "constraints-source-providers")
set_value_to_default_if_not_set(env, 'AIRFLOW_CONSTRAINTS_REFERENCE', DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH)
set_value_to_default_if_not_set(env, 'AIRFLOW_EXTRAS', "")
set_value_to_default_if_not_set(env, 'ANSWER', "")
set_value_to_default_if_not_set(env, 'BREEZE', "true")
Expand All @@ -470,7 +469,6 @@ def update_expected_environment_variables(env: Dict[str, str]) -> None:
set_value_to_default_if_not_set(env, 'DB_RESET', "false")
set_value_to_default_if_not_set(env, 'DEBIAN_VERSION', "bullseye")
set_value_to_default_if_not_set(env, 'DEFAULT_BRANCH', AIRFLOW_BRANCH)
set_value_to_default_if_not_set(env, 'DEFAULT_CONSTRAINTS_BRANCH', DEFAULT_AIRFLOW_CONSTRAINTS_BRANCH)
set_value_to_default_if_not_set(env, 'ENABLED_SYSTEMS', "")
set_value_to_default_if_not_set(env, 'ENABLE_TEST_COVERAGE', "false")
set_value_to_default_if_not_set(env, 'GITHUB_REGISTRY_PULL_IMAGE_TAG', "latest")
Expand Down Expand Up @@ -504,7 +502,6 @@ def update_expected_environment_variables(env: Dict[str, str]) -> None:
"AIRFLOW_CI_IMAGE_WITH_TAG": "airflow_image_name_with_tag",
"AIRFLOW_EXTRAS": "airflow_extras",
"AIRFLOW_CONSTRAINTS_MODE": "airflow_constraints_mode",
"AIRFLOW_CONSTRAINTS_REFERENCE": "airflow_constraints_reference",
"AIRFLOW_IMAGE_KUBERNETES": "airflow_image_kubernetes",
"AIRFLOW_PROD_IMAGE": "airflow_image_name",
"AIRFLOW_SOURCES": "airflow_sources",
Expand Down
2 changes: 1 addition & 1 deletion images/breeze/output-commands-hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ab4be8e4ea37747cdbb1a4ad12ea5e33
aa34cfc99f60649fea3b808ef225981e