Skip to content
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
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ repos:
^generated/provider_dependencies.json$
require_serial: true
pass_filenames: false
additional_dependencies: ['rich>=12.4.4', 'rich-click>=1.7.0', 'inputimeout', 'pyyaml', 'packaging']
additional_dependencies: ['rich>=12.4.4', 'rich-click>=1.7.0', 'inputimeout', 'pyyaml', 'packaging', 'filelock']
- id: check-example-dags-urls
name: Check that example dags url include provider versions
entry: ./scripts/ci/pre_commit/pre_commit_update_example_dags_paths.py
Expand Down Expand Up @@ -1025,50 +1025,50 @@ repos:
entry: ./scripts/ci/pre_commit/pre_commit_mypy.py
files: ^dev/.*\.py$
require_serial: true
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml', 'jsonschema']
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml', 'jsonschema', 'filelock', 'markdown-it-py']
- id: mypy-core
name: Run mypy for core
language: python
entry: ./scripts/ci/pre_commit/pre_commit_mypy.py --namespace-packages
files: \.py$
exclude: ^.*/.*_vendor/|^airflow/migrations|^airflow/providers|^dev|^docs|^provider_packages|^tests/providers|^tests/system/providers|^tests/dags/test_imports.py
require_serial: true
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml', 'jsonschema']
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml', 'jsonschema', 'filelock', 'markdown-it-py']
- id: mypy-providers
name: Run mypy for providers
language: python
entry: ./scripts/ci/pre_commit/pre_commit_mypy.py --namespace-packages
files: ^airflow/providers/.*\.py$|^tests/providers/.*\.py$|^tests/system/providers/.*\.py$
exclude: ^.*/.*_vendor/
require_serial: true
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml', 'jsonschema']
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml', 'jsonschema', 'filelock', 'markdown-it-py']
- id: mypy-docs
name: Run mypy for /docs/ folder
language: python
entry: ./scripts/ci/pre_commit/pre_commit_mypy.py
files: ^docs/.*\.py$
exclude: ^docs/rtd-deprecation
require_serial: true
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml', 'jsonschema']
- id: check-provider-yaml-valid
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml', 'jsonschema', 'filelock', 'markdown-it-py']
- id: check-provider-yaml-valid
name: Validate provider.yaml files
entry: ./scripts/ci/pre_commit/pre_commit_check_provider_yaml_files.py
language: python
files: ^airflow/providers/.*/provider\.yaml$
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'markdown-it-py']
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml', 'jsonschema', 'filelock', 'markdown-it-py']
require_serial: true
- id: update-migration-references
name: Update migration ref doc
language: python
entry: ./scripts/ci/pre_commit/pre_commit_migration_reference.py
pass_filenames: false
files: ^airflow/migrations/versions/.*\.py$|^docs/apache-airflow/migrations-ref\.rst$
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'markdown-it-py']
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml', 'jsonschema', 'filelock', 'markdown-it-py']
- id: update-er-diagram
name: Update ER diagram
language: python
entry: ./scripts/ci/pre_commit/pre_commit_update_er_diagram.py
pass_filenames: false
files: ^airflow/migrations/versions/.*\.py$|^docs/apache-airflow/migrations-ref\.rst$
additional_dependencies: ['rich>=12.4.4']
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml', 'jsonschema', 'filelock', 'markdown-it-py']
## ONLY ADD PRE-COMMITS HERE THAT REQUIRE CI IMAGE
39 changes: 21 additions & 18 deletions dev/breeze/src/airflow_breeze/commands/developer_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
from airflow_breeze.utils.docker_command_utils import (
check_docker_resources,
fix_ownership_using_docker,
get_env_variables_for_docker_commands,
get_extra_docker_flags,
perform_environment_checks,
)
Expand Down Expand Up @@ -431,17 +430,17 @@ def build_docs(
perform_environment_checks()
fix_ownership_using_docker()
cleanup_python_generated_files()
params = BuildCiParams(
build_params = BuildCiParams(
github_repository=github_repository, python=DEFAULT_PYTHON_MAJOR_MINOR_VERSION, builder=builder
)
rebuild_or_pull_ci_image_if_needed(command_params=params)
rebuild_or_pull_ci_image_if_needed(command_params=build_params)
if clean_build:
docs_dir = AIRFLOW_SOURCES_ROOT / "docs"
for dir_name in ["_build", "_doctrees", "_inventory_cache", "_api"]:
for directory in docs_dir.rglob(dir_name):
get_console().print(f"[info]Removing {directory}")
shutil.rmtree(directory, ignore_errors=True)
ci_image_name = params.airflow_image_name
ci_image_name = build_params.airflow_image_name
doc_builder = DocBuildParams(
package_filter=package_filter,
docs_only=docs_only,
Expand All @@ -450,8 +449,11 @@ def build_docs(
skip_environment_initialization=True,
short_doc_packages=expand_all_provider_packages(doc_packages),
)
extra_docker_flags = get_extra_docker_flags(MOUNT_SELECTED)
env = get_env_variables_for_docker_commands(params)
shell_params = ShellParams(
github_repository=github_repository,
python=DEFAULT_PYTHON_MAJOR_MINOR_VERSION,
)
extra_docker_flags = get_extra_docker_flags(mount_sources=MOUNT_SELECTED)
cmd = [
"docker",
"run",
Expand All @@ -463,7 +465,7 @@ def build_docs(
"/opt/airflow/scripts/in_container/run_docs_build.sh",
*doc_builder.args_doc_builder,
]
process = run_command(cmd, text=True, env=env, check=False)
process = run_command(cmd, text=True, check=False, env=shell_params.env_variables_for_docker_commands)
fix_ownership_using_docker()
if process.returncode == 0:
get_console().print(
Expand Down Expand Up @@ -714,11 +716,10 @@ def down(preserve_volumes: bool, cleanup_mypy_cache: bool):
if not preserve_volumes:
command_to_execute.append("--volumes")
shell_params = ShellParams(backend="all", include_mypy_volume=True)
env_variables = get_env_variables_for_docker_commands(shell_params)
run_command(command_to_execute, env=env_variables)
run_command(command_to_execute, env=shell_params.env_variables_for_docker_commands)
if cleanup_mypy_cache:
command_to_execute = ["docker", "volume", "rm", "--force", "mypy-cache-volume"]
run_command(command_to_execute, env=env_variables)
run_command(command_to_execute)


@main.command(name="exec", help="Joins the interactive shell of running airflow container.")
Expand Down Expand Up @@ -796,9 +797,8 @@ def enter_shell(**kwargs) -> RunCommandResult:
if shell_params.include_mypy_volume:
create_mypy_volume_if_needed()
shell_params.print_badge_info()
cmd = ["docker", "compose", "run", "--service-ports", "-e", "BREEZE", "--rm", "airflow"]
cmd = ["docker", "compose", "run", "--service-ports", "--rm", "airflow"]
cmd_added = shell_params.command_passed
env_variables = get_env_variables_for_docker_commands(shell_params)
if cmd_added is not None:
cmd.extend(["-c", cmd_added])
if "arm64" in DOCKER_DEFAULT_PLATFORM:
Expand All @@ -817,7 +817,11 @@ def enter_shell(**kwargs) -> RunCommandResult:
sys.exit(1)

command_result = run_command(
cmd, env=env_variables, text=True, check=False, output_outside_the_group=True
cmd,
text=True,
check=False,
env=shell_params.env_variables_for_docker_commands,
output_outside_the_group=True,
)
if command_result.returncode == 0:
return command_result
Expand All @@ -834,13 +838,12 @@ def stop_exec_on_error(returncode: int):


def find_airflow_container() -> str | None:
exec_shell_params = ShellParams()
check_docker_resources(exec_shell_params.airflow_image_name)
exec_shell_params.print_badge_info()
env_variables = get_env_variables_for_docker_commands(exec_shell_params)
shell_params = ShellParams()
check_docker_resources(shell_params.airflow_image_name)
shell_params.print_badge_info()
cmd = ["docker", "compose", "ps", "--all", "--filter", "status=running", "airflow"]
docker_compose_ps_command = run_command(
cmd, text=True, capture_output=True, env=env_variables, check=False
cmd, text=True, capture_output=True, check=False, env=shell_params.env_variables_for_docker_commands
)
if get_dry_run():
return "CONTAINER_ID"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
from airflow_breeze.utils.docker_command_utils import (
check_remote_ghcr_io_commands,
fix_ownership_using_docker,
get_env_variables_for_docker_commands,
get_extra_docker_flags,
perform_environment_checks,
)
Expand Down Expand Up @@ -149,15 +148,15 @@


def run_docker_command_with_debug(
params: ShellParams,
shell_params: ShellParams,
command: list[str],
debug: bool,
enable_input: bool = False,
output_outside_the_group: bool = False,
**kwargs,
) -> RunCommandResult:
env_variables = get_env_variables_for_docker_commands(params)
extra_docker_flags = get_extra_docker_flags(mount_sources=params.mount_sources)
env = shell_params.env_variables_for_docker_commands
extra_docker_flags = get_extra_docker_flags(mount_sources=shell_params.mount_sources)
if enable_input or debug:
term_flag = "-it"
else:
Expand All @@ -169,7 +168,7 @@ def run_docker_command_with_debug(
*extra_docker_flags,
"--pull",
"never",
params.airflow_image_name_with_tag,
shell_params.airflow_image_name_with_tag,
]
if debug:
cmd_string = " ".join([shlex.quote(s) for s in command if s != "-c"])
Expand All @@ -187,16 +186,16 @@ def run_docker_command_with_debug(
)
return run_command(
base_command,
env=env_variables,
output_outside_the_group=output_outside_the_group,
env=env,
**kwargs,
)
else:
base_command.extend(command)
return run_command(
base_command,
env=env_variables,
check=False,
env=env,
output_outside_the_group=output_outside_the_group,
**kwargs,
)
Expand Down Expand Up @@ -610,7 +609,7 @@ def run_generate_constraints(
"/opt/airflow/scripts/in_container/run_generate_constraints.sh",
]
generate_constraints_result = run_docker_command_with_debug(
params=shell_params,
shell_params=shell_params,
command=cmd_to_run,
debug=debug,
output=output,
Expand Down Expand Up @@ -825,7 +824,7 @@ def _run_command_for_providers(
) -> tuple[int, str]:
shell_params.install_selected_providers = " ".join(list_of_providers)
result_command = run_docker_command_with_debug(
params=shell_params,
shell_params=shell_params,
command=cmd_to_run,
debug=False,
output=output,
Expand Down Expand Up @@ -957,7 +956,7 @@ def install_provider_packages(
)
else:
result_command = run_docker_command_with_debug(
params=shell_params,
shell_params=shell_params,
command=cmd_to_run,
debug=debug,
output_outside_the_group=True,
Expand Down Expand Up @@ -999,6 +998,8 @@ def verify_provider_packages(
fix_ownership_using_docker()
cleanup_python_generated_files()
shell_params = ShellParams(
backend="sqlite",
executor="SequentialExecutor",
mount_sources=MOUNT_SELECTED,
github_repository=github_repository,
python=DEFAULT_PYTHON_MAJOR_MINOR_VERSION,
Expand All @@ -1015,7 +1016,7 @@ def verify_provider_packages(
"python /opt/airflow/scripts/in_container/verify_providers.py",
]
result_command = run_docker_command_with_debug(
params=shell_params,
shell_params=shell_params,
command=cmd_to_run,
debug=debug,
output_outside_the_group=True,
Expand Down
Loading