-
Notifications
You must be signed in to change notification settings - Fork 184
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
[Feature] Refactor and add support for schedule conditions in DAG configuration: #320
Open
ErickSeo
wants to merge
9
commits into
astronomer:main
Choose a base branch
from
ErickSeo:feat/enable_schedule_dataset_condition
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Feature] Refactor and add support for schedule conditions in DAG configuration: #320
ErickSeo
wants to merge
9
commits into
astronomer:main
from
ErickSeo:feat/enable_schedule_dataset_condition
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added support for schedules defined by conditions, enabling dynamic scheduling based on dataset filters and conditions. - Introduced `configure_schedule` function to streamline DAG schedule setup based on Airflow version and parameters. - Created `process_file_with_datasets` function to handle dataset processing and conditional evaluation from files. - Implemented `evaluate_condition_with_datasets` to evaluate schedule conditions while ensuring valid variable names for dataset URIs. - Replaced repetitive code with reusable functions for better modularity and maintainability. - Enhanced code readability by adding detailed docstrings for all functions, following a standard format. - Improved safety by avoiding reliance on `globals()` in `evaluate_condition_with_datasets`.
1 task
- Implemented logic to handle schedules with both file and datasets attributes. - Added support for evaluating conditions with datasets for Airflow version 2.9 and above. - Cleaned up schedule dictionary by removing processed keys.
- Added logic to handle schedules with both file and datasets attributes. - Implemented support for evaluating conditions with datasets for Airflow version 2.9 and above. - Cleaned up schedule dictionary by removing processed keys after use.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #320 +/- ##
==========================================
+ Coverage 93.29% 93.33% +0.03%
==========================================
Files 10 10
Lines 776 825 +49
==========================================
+ Hits 724 770 +46
- Misses 52 55 +3 ☔ View full report in Codecov by Sentry. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This feature introduces a enhancement to DAG scheduling in Airflow, enabling support for dynamic schedules based on dataset conditions. By leveraging dataset filters and logical conditions, users can now create more flexible and precise scheduling rules tailored to their workflows.
Key Features:
Condition-Based Scheduling: Allows defining schedules using logical conditions between datasets (e.g., ('dataset_1' & 'dataset_2') | 'dataset_3'), enabling workflows to trigger dynamically based on dataset availability.
Dynamic Dataset Processing: Introduced the process_file_with_datasets function to evaluate and process dataset URIs from external files, supporting both simple and condition-based schedules.
Improved Dataset Evaluation: Developed the evaluate_condition_with_datasets function to transform dataset URIs into valid variable names and evaluate logical conditions securely.
Workflow Example:
Given the following condition:
The system evaluates the datasets, ensuring valid references, and schedules the DAG dynamically when the condition resolves to True.
Example Use Case:
Consider a data pipeline that processes files only when multiple interdependent datasets are updated. With this feature, users can create dynamic DAG schedules that automatically adjust based on dataset availability and conditions, optimizing resource allocation and execution timing.
Images: