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

Don't create session in get_dag if not reading dags from database #38553

Conversation

dstandish
Copy link
Contributor

@dstandish dstandish commented Mar 27, 2024

The function DagBag.get_dag has some logic to check if the serialized dag object should be refreshed. By accessing the dags dict directly we avoid that logic, and this is helpful for running a task exclusively with the internal API. Generally speaking this function "get_dag" is invoked when running the task command on a worker, and in that context we shouldn't need to handle expiration of the serdag. For the case where we're reading from db, I have left the original method call in place (which keeps the expiration logic in effect for that scenario).

@potiuk
Copy link
Member

potiuk commented Mar 27, 2024

Tests failing.

@dstandish dstandish force-pushed the dont-make-unnecessary-network-calls-with-dag-related-commands branch from 786b0c7 to 9cc89e6 Compare April 1, 2024 17:46
@dstandish
Copy link
Contributor Author

Tests failing.

should be resolved now 🤞

@dstandish dstandish force-pushed the dont-make-unnecessary-network-calls-with-dag-related-commands branch from 9cc89e6 to b0c244c Compare April 1, 2024 17:53
The function DagBag.get_dag has some logic to check if the serialized dag object should be refreshed. By accessing the dags dict directly we avoid that logic, and this is helpful for running a task exclusively with the internal API.  Generally speaking this function "get_dag" is invoked when running the task command on a worker, and in that context we shouldn't need to handle expiration of the serdag.  For the case where we're reading from db, I have left the original method call in place (which keeps the expiration logic in effect for that scenario).
@dstandish dstandish force-pushed the dont-make-unnecessary-network-calls-with-dag-related-commands branch from b0c244c to 6a06ee4 Compare April 1, 2024 17:54
@dstandish dstandish changed the title Don't make unnecessary network calls with dag-related commands Don't create session in get_dag if not reading dags from database Apr 1, 2024
airflow/utils/cli.py Outdated Show resolved Hide resolved
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
@dstandish dstandish merged commit eba5046 into apache:main Apr 2, 2024
41 checks passed
@dstandish dstandish deleted the dont-make-unnecessary-network-calls-with-dag-related-commands branch April 2, 2024 16:16
@ephraimbuddy ephraimbuddy added type:improvement Changelog: Improvements AIP-44 Airflow Internal API labels Jun 3, 2024
@dstandish dstandish added this to the Airflow 2.10.0 milestone Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AIP-44 Airflow Internal API type:improvement Changelog: Improvements
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants