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
2 changes: 1 addition & 1 deletion airflow-core/tests/unit/charts/helm_template_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def render_chart(
if show_only:
for i in show_only:
command.extend(["--show-only", i])
result = subprocess.run(command, capture_output=True, cwd=chart_dir)
result = subprocess.run(command, check=False, capture_output=True, cwd=chart_dir)
if result.returncode:
raise HelmFailedError(result.returncode, result.args, result.stdout, result.stderr)
templates = result.stdout
Expand Down
5 changes: 4 additions & 1 deletion dev/breeze/src/airflow_breeze/utils/publish_docs_to_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ def sync_docs_to_s3(self, source: str, destination: str):
return (0, "")
get_console().print(f"[info]Syncing {source} to {destination}\n")
result = subprocess.run(
["aws", "s3", "sync", "--delete", source, destination], capture_output=True, text=True
["aws", "s3", "sync", "--delete", source, destination],
check=False,
capture_output=True,
text=True,
)
return (result.returncode, result.stderr)

Expand Down
2 changes: 2 additions & 0 deletions devel-common/src/sphinx_exts/docs_build/docs_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def check_spelling(self, verbose: bool) -> tuple[list[SpellingError], list[DocBu
with open(self.log_spelling_filename, "w") as output:
completed_proc = run(
build_cmd,
check=False,
cwd=AIRFLOW_CONTENT_ROOT_PATH,
env=env,
stdout=output if not verbose else None,
Expand Down Expand Up @@ -274,6 +275,7 @@ def build_sphinx_docs(self, verbose: bool) -> list[DocBuildError]:
with open(self.log_build_filename, "w") as output:
completed_proc = run(
build_cmd,
check=False,
cwd=AIRFLOW_CONTENT_ROOT_PATH,
env=env,
stdout=output if not verbose else None,
Expand Down
2 changes: 1 addition & 1 deletion helm-tests/tests/chart_utils/helm_template_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def render_chart(
if show_only:
for i in show_only:
command.extend(["--show-only", i])
result = subprocess.run(command, capture_output=True, cwd=chart_dir)
result = subprocess.run(command, check=False, capture_output=True, cwd=chart_dir)
if result.returncode:
raise HelmFailedError(result.returncode, result.args, result.stdout, result.stderr)
templates = result.stdout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ def run_and_report(command, task_key):
try:
log.info("Starting execution for task: %s", task_key)
result = subprocess.run(
command, shell=isinstance(command, str), stdout=subprocess.PIPE, stderr=subprocess.STDOUT
command,
check=False,
shell=isinstance(command, str),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
return_code = result.returncode
log.info("Execution completed for task %s with return code %s", task_key, return_code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,14 @@ def _execute_in_subprocess(command_to_exec: CommandType, celery_task_id: str | N
if celery_task_id:
env["external_executor_id"] = celery_task_id
try:
subprocess.run(command_to_exec, stderr=sys.__stderr__, stdout=sys.__stdout__, close_fds=True, env=env)
subprocess.run(
command_to_exec,
check=False,
stderr=sys.__stderr__,
stdout=sys.__stdout__,
close_fds=True,
env=env,
)
except subprocess.CalledProcessError as e:
log.exception("[%s] execute_command encountered a CalledProcessError", celery_task_id)
log.error(e.output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ def _generate_login_token(self, service_account) -> str:
cloud_sql_hook = CloudSQLHook(api_version="v1", gcp_conn_id=self.gcp_conn_id)

with cloud_sql_hook.provide_authorized_gcloud():
proc = subprocess.run(cmd, capture_output=True)
proc = subprocess.run(cmd, check=False, capture_output=True)

if proc.returncode != 0:
stderr_last_20_lines = "\n".join(proc.stderr.decode().strip().splitlines()[-20:])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ def _create_dataflow_job_with_gcloud(self, cmd: list[str]) -> str:
success_code = 0

with self.provide_authorized_gcloud():
proc = subprocess.run(cmd, capture_output=True)
proc = subprocess.run(cmd, check=False, capture_output=True)

if proc.returncode != success_code:
stderr_last_20_lines = "\n".join(proc.stderr.decode().strip().splitlines()[-20:])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def _create_dataproc_cluster_with_gcloud(self, cmd: list[str]) -> str:
success_code = 0

with self.provide_authorized_gcloud():
proc = subprocess.run(cmd, capture_output=True)
proc = subprocess.run(cmd, check=False, capture_output=True)

if proc.returncode != success_code:
stderr_last_20_lines = "\n".join(proc.stderr.decode().strip().splitlines()[-20:])
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ extend-select = [
"PLW1501", # {mode} is not a valid mode for open
"PLW1507", # Shallow copy of os.environ via copy.copy(os.environ)
"PLW1508", # Invalid type for environment variable default; expected str or None
"PLW1510", # subprocess.run without explicit check argument
# Per rule enables
"RUF006", # Checks for asyncio dangling task
"RUF015", # Checks for unnecessary iterable allocation for first element
Expand Down
2 changes: 1 addition & 1 deletion scripts/in_container/in_container_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def run_command(cmd: list[str], github_actions: bool, **kwargs) -> subprocess.Co
with ci_group(
f"Running command: {' '.join([shlex.quote(arg) for arg in cmd])}", github_actions=github_actions
):
result = subprocess.run(cmd, **kwargs)
result = subprocess.run(cmd, **kwargs) # noqa: PLW1510 - check is handled below and added by callers
if result.returncode != 0 and github_actions and kwargs.get("check", False):
console.print(f"[red]Command failed: {' '.join([shlex.quote(entry) for entry in cmd])}[/]")
console.print("[red]Please unfold the above group and to investigate the issue[/]")
Expand Down
4 changes: 2 additions & 2 deletions scripts/in_container/run_check_default_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
# Write default config cmd output to a temporary file
default_config_file = os.path.join(tmp_dir, "airflow.cfg")
with open(default_config_file, "w") as f:
result = subprocess.run(list_default_config_cmd, stdout=f)
result = subprocess.run(list_default_config_cmd, check=False, stdout=f)
if result.returncode != 0:
print(f"\033[0;31mERROR: when running `{' '.join(list_default_config_cmd)}`\033[0m\n")
exit(1)
# Run airflow config lint to check the default config
env = os.environ.copy()
env["AIRFLOW_HOME"] = tmp_dir
env["AIRFLOW_CONFIG"] = default_config_file
result = subprocess.run(lint_config_cmd, capture_output=True, env=env)
result = subprocess.run(lint_config_cmd, check=False, capture_output=True, env=env)

output: str = result.stdout.decode().strip()
if result.returncode != 0 or expected_output not in output:
Expand Down
2 changes: 2 additions & 0 deletions scripts/in_container/run_prepare_airflow_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def build_airflow_packages(distribution_format: str):
console.print(f"[bright_blue]Building apache-airflow-core distributions: {distribution_format}\n")
build_process = subprocess.run(
airflow_core_build_command,
check=False,
capture_output=False,
cwd=AIRFLOW_CORE_ROOT_PATH,
env=envcopy,
Expand All @@ -105,6 +106,7 @@ def build_airflow_packages(distribution_format: str):
console.print(f"[bright_blue]Building apache-airflow distributions: {distribution_format}\n")
build_process = subprocess.run(
airflow_build_command,
check=False,
capture_output=False,
cwd=AIRFLOW_ROOT_PATH,
env=envcopy,
Expand Down
8 changes: 4 additions & 4 deletions scripts/tools/initialize_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def uv_install_requirements() -> int:
quoted_command = " ".join([shlex.quote(parameter) for parameter in uv_install_command])
print()
print(f"Running command: \n {quoted_command}\n")
e = subprocess.run(uv_install_command)
e = subprocess.run(uv_install_command, check=False)
return e.returncode


Expand All @@ -116,7 +116,7 @@ def main():

if not check_if_in_virtualenv():
version = get_python_version()
e = subprocess.run(["uv", "venv", "--python", version])
e = subprocess.run(["uv", "venv", "--python", version], check=False)
if e.returncode != 0:
print(f"There was a problem with 'uv venv'. Error code: {e.returncode}")

Expand Down Expand Up @@ -168,7 +168,7 @@ def main():
env["AIRFLOW__DATABASE__SQL_ALCHEMY_POOL_ENABLED"] = "False"
env["AIRFLOW__CORE__DAGS_FOLDER"] = f"{airflow_sources}/empty"
env["AIRFLOW__CORE__PLUGINS_FOLDER"] = f"{airflow_sources}/empty"
subprocess.run(["uv", "run", "airflow", "db", "reset", "--yes"], env=env)
subprocess.run(["uv", "run", "airflow", "db", "reset", "--yes"], check=False, env=env)

print("\nResetting AIRFLOW sqlite unit test database...")
env = os.environ.copy()
Expand All @@ -177,7 +177,7 @@ def main():
env["AIRFLOW__DATABASE__SQL_ALCHEMY_POOL_ENABLED"] = "False"
env["AIRFLOW__CORE__DAGS_FOLDER"] = f"{airflow_sources}/empty"
env["AIRFLOW__CORE__PLUGINS_FOLDER"] = f"{airflow_sources}/empty"
subprocess.run(["uv", "run", "airflow", "db", "reset", "--yes"], env=env)
subprocess.run(["uv", "run", "airflow", "db", "reset", "--yes"], check=False, env=env)

print("\nInitialization of environment complete! Go ahead and develop Airflow!")

Expand Down