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

Add teardown task #1529

Merged
merged 14 commits into from
Feb 13, 2025
Merged

Add teardown task #1529

merged 14 commits into from
Feb 13, 2025

Conversation

pankajastro
Copy link
Contributor

@pankajastro pankajastro commented Feb 10, 2025

This PR introduces a teardown node in the Cosmos DAG that deletes SQL files from the remote location that were uploaded by the setup task. This ensures proper cleanup of resources after the task execution.

Key Changes:

Teardown Node Addition:

A new teardown task is added to the Cosmos DAG that deletes the SQL files from the remote location. The files deleted are the ones uploaded by the setup task earlier in the DAG.
New Config: enable_teardown_async_task:

A configuration option enable_teardown_async_task, is introduced to enable or disable this feature. This config is enabled by default.
Setting this config to False will skip the teardown step, while setting it to True will ensure the deletion task runs after the setup.

Applicable Only for AIRFLOW_ASYNC Execution Mode:

This feature is only triggered when the DAG is running in AIRFLOW_ASYNC execution mode

Screenshot 2025-02-12 at 6 17 08 PM

closes: #1232

Copy link

netlify bot commented Feb 10, 2025

Deploy Preview for sunny-pastelito-5ecb04 canceled.

Name Link
🔨 Latest commit 81ae672
🔍 Latest deploy log https://app.netlify.com/sites/sunny-pastelito-5ecb04/deploys/67adfb1a67e46f0008c2cf86

Copy link

cloudflare-workers-and-pages bot commented Feb 10, 2025

Deploying astronomer-cosmos with  Cloudflare Pages  Cloudflare Pages

Latest commit: 81ae672
Status: ✅  Deploy successful!
Preview URL: https://87afda90.astronomer-cosmos.pages.dev
Branch Preview URL: https://teardown-task.astronomer-cosmos.pages.dev

View logs

Copy link
Collaborator

@tatiana tatiana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pankajastro some early feedback. Please, could you confirm that the teardown task is not emitting any datasets (outlets)

cosmos/airflow/graph.py Outdated Show resolved Hide resolved
cosmos/airflow/graph.py Outdated Show resolved Hide resolved
cosmos/airflow/graph.py Outdated Show resolved Hide resolved
cosmos/operators/local.py Show resolved Hide resolved
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.32%. Comparing base (a43a991) to head (81ae672).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1529      +/-   ##
==========================================
+ Coverage   97.30%   97.32%   +0.02%     
==========================================
  Files          80       80              
  Lines        4784     4821      +37     
==========================================
+ Hits         4655     4692      +37     
  Misses        129      129              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pankajastro pankajastro marked this pull request as ready for review February 12, 2025 14:12
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 12, 2025
@dosubot dosubot bot added area:config Related to configuration, like YAML files, environment variables, or executer configuration area:docs Relating to documentation, changes, fixes, improvement area:execution Related to the execution environment/mode, like Docker, Kubernetes, Local, VirtualEnv, etc labels Feb 12, 2025
@pankajastro
Copy link
Contributor Author

Hi @pankajastro some early feedback. Please, could you confirm that the teardown task is not emitting any datasets (outlets)

Yes, teardown task do not emit any datasets

Copy link
Contributor

@pankajkoti pankajkoti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Looks like we have a conflict with main that needs to be resolved.

cosmos/settings.py Outdated Show resolved Hide resolved
@pankajastro pankajastro merged commit 745ed14 into main Feb 13, 2025
69 checks passed
@pankajastro pankajastro deleted the teardown_task branch February 13, 2025 16:36
@pankajkoti pankajkoti mentioned this pull request Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:config Related to configuration, like YAML files, environment variables, or executer configuration area:docs Relating to documentation, changes, fixes, improvement area:execution Related to the execution environment/mode, like Docker, Kubernetes, Local, VirtualEnv, etc size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[async] Introduce teardown node when using ExecutionMode.AIRFLOW_ASYNC
3 participants