-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Alias task_display_name
for EventLogResponse
#55160
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
base: main
Are you sure you want to change the base?
Conversation
660d08e
to
5a2d4f4
Compare
task_display_name: str | None = Field( | ||
validation_alias=AliasPath("task_instance", "task_display_name"), default=None | ||
) |
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 think this can ever be None? TaskInstance always defaults to task_id if the column does not contain a value.
Actually dag_display_name also cannot be None as far as I can tell. Maybe we should fix it too.
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 think it might be null. Since dag_id
and task_id
can also be None
here, it means the relationships to dag_model
and task_instance
can be both None
, which indicates that display_name
is possible to be None
.
However, when they do exist, the display names should always be never None
as confirmed by the hybrid property logic like what you said. Please let me know if I've misunderstood anything, thanks!
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 I get the context correctly, there will be the cases where dag_id
and task_id
both will be None
.
Take delete_asset_queued_events
route as example:
airflow/airflow-core/src/airflow/api_fastapi/core_api/routes/public/assets.py
Lines 554 to 563 in c29696c
@assets_router.delete( | |
"/assets/{asset_id}/queuedEvents", | |
status_code=status.HTTP_204_NO_CONTENT, | |
responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]), | |
dependencies=[ | |
Depends(requires_access_asset(method="DELETE")), | |
Depends(requires_access_dag(method="GET")), | |
Depends(action_logging()), | |
], | |
) |
We can't get either dag_id
or task_id
from the query params and path params.
airflow/airflow-core/src/airflow/api_fastapi/logging/decorators.py
Lines 140 to 150 in c29696c
# Create log entry | |
log = Log( | |
event=event_name, | |
task_instance=None, | |
owner=user_name, | |
owner_display_name=user_display, | |
extra=json.dumps(extra_fields), | |
task_id=params.get("task_id"), | |
dag_id=params.get("dag_id"), | |
run_id=params.get("run_id") or params.get("dag_run_id"), | |
) |
task_instance = relationship( | ||
"TaskInstance", | ||
viewonly=True, | ||
lazy="selectin", |
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.
Any specific reason behind this lazy strat?
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 put it for preventing N+1 queries but it seems redundant here. Let me remove it. Thanks for catching this.
5a2d4f4
to
09e7e2a
Compare
09e7e2a
to
3c90f03
Compare
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.
Nice! Thanks for the PR!
task_display_name: str | None = Field( | ||
validation_alias=AliasPath("task_instance", "task_display_name"), default=None | ||
) |
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 I get the context correctly, there will be the cases where dag_id
and task_id
both will be None
.
Take delete_asset_queued_events
route as example:
airflow/airflow-core/src/airflow/api_fastapi/core_api/routes/public/assets.py
Lines 554 to 563 in c29696c
@assets_router.delete( | |
"/assets/{asset_id}/queuedEvents", | |
status_code=status.HTTP_204_NO_CONTENT, | |
responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]), | |
dependencies=[ | |
Depends(requires_access_asset(method="DELETE")), | |
Depends(requires_access_dag(method="GET")), | |
Depends(action_logging()), | |
], | |
) |
We can't get either dag_id
or task_id
from the query params and path params.
airflow/airflow-core/src/airflow/api_fastapi/logging/decorators.py
Lines 140 to 150 in c29696c
# Create log entry | |
log = Log( | |
event=event_name, | |
task_instance=None, | |
owner=user_name, | |
owner_display_name=user_display, | |
extra=json.dumps(extra_fields), | |
task_id=params.get("task_id"), | |
dag_id=params.get("dag_id"), | |
run_id=params.get("run_id") or params.get("dag_run_id"), | |
) |
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.
Looks good to me. We can merge once other comments are resolved.
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.
LGTM as well
Related Issue
#46730
How
task_display_name
forEventLogResponse
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in airflow-core/newsfragments.