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 getting the dag/task ids from base executor #27550

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/executors/base_executor.py
Expand Up @@ -363,7 +363,7 @@ def validate_airflow_tasks_run_command(command: list[str]) -> tuple[str | None,
if len(command) > 3 and "--help" not in command:
dag_id: str | None = None
task_id: str | None = None
for arg in command[4:]:
for arg in command[3:]:
if not arg.startswith("--"):
if dag_id is None:
dag_id = arg
Expand Down
7 changes: 7 additions & 0 deletions tests/executors/test_base_executor.py
Expand Up @@ -125,3 +125,10 @@ def test_trigger_running_tasks(dag_maker, change_state_attempt):
assert len(executor.execute_async.mock_calls) == len(dagrun.task_instances) + 1
else:
assert len(executor.execute_async.mock_calls) == len(dagrun.task_instances)


def test_validate_airflow_tasks_run_command(dag_maker):
dagrun = setup_dagrun(dag_maker)
tis = dagrun.task_instances
dag_id, task_id = BaseExecutor.validate_airflow_tasks_run_command(tis[0].command_as_list())
assert dag_id == dagrun.dag_id and task_id == tis[0].task_id