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
Make execution_date_or_run_id
optional in tasks test
command
#26114
Make execution_date_or_run_id
optional in tasks test
command
#26114
Conversation
execution_date_or_run_id
an optional argument for tasks test
…execution_date_or_run_id
optional tasks test
command
ARG_EXECUTION_DATE_OR_RUN_ID = Arg( | ||
('execution_date_or_run_id',), help="The execution_date of the DAG or run_id of the DAGRun" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you not need to delete this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's used elsewhere
What's the reason for this? Because right now everything in Airflow task execution is for a specific date, So given Do any docs need updating too? |
Right, it's always "there" for airlfow, at least internally. But often times as a task developer you don't care about the execution_date. E.g. when catchup=False, probably you aren't really concerned with it. For those cases, it's nice to just be able to run the task and not have to pick an arbitrary date you don't care about, just so you can run your task via CLI.
Should be same as if you put today UTC in for execution_date.
i'll take a look. |
0a90ae3
to
cdb1f39
Compare
execution_date_or_run_id
optional tasks test
commandexecution_date_or_run_id
optional in tasks test
command
2040fb2
to
efb1fa6
Compare
efb1fa6
to
c5a5137
Compare
did make the small adjustments required in the docs. and i think it will build green now -- was just a static check remaining. |
airflow/cli/commands/task_command.py
Outdated
create_if_necessary: CreateIfNecessary, | ||
session: Session, | ||
exec_date_or_run_id: Optional[str] = None, | ||
session: Session = NEW_SESSION, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we make this default session change, should we also @provide_session
this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't see why the one should prompt the other. the NEW_SESSION change doesn't really change the behavior of the function. the reason it's there in general is this:
# A fake session to use in functions decorated by provide_session. This allows
# the 'session' argument to be of type Session instead of Optional[Session],
# making it easier to type hint the function body without dealing with the None
# case that can never happen at runtime.
but for me, i'm adding it here simply because i want to keep it as the last argument, so to do so, it needs a default, since i'm making exec date optional.
but what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All arguments in this function are keyword-only, so ordering does not matter. You can add the new argument anywhere (but behind *
) and keep all other arguments as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can keep it last, keyword-only means you don’t need to add a default to keep it last.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯
No description provided.