-
Notifications
You must be signed in to change notification settings - Fork 235
[Feature] Refactor and add support for schedule conditions in DAG configuration: #320
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
Merged
tatiana
merged 25 commits into
astronomer:main
from
ErickSeo:feat/enable_schedule_dataset_condition
Jan 10, 2025
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
4ba99db
Refactor and add support for schedule conditions in DAG configuration:
hiroyukiiseo-hue 4413aad
add utils unit tests
hiroyukiiseo-hue 5eddb01
fix unit test
hiroyukiiseo-hue ba3ea4b
fix:
hiroyukiiseo-hue daa5502
feat: add support for processing schedules with conditions and datasets
hiroyukiiseo-hue 74effa6
lint
hiroyukiiseo-hue 84c3172
feat: enhance schedule processing with conditions and datasets
hiroyukiiseo-hue 08d1fa7
fix unit test
hiroyukiiseo-hue 89854a8
fix ruff
hiroyukiiseo-hue 6d26a15
Merge branch 'main' into feat/enable_schedule_dataset_condition
tatiana 995931f
Format __all__ declaration for consistency
hiroyukiiseo-hue 8e2068f
Refactor dataset conditions in example DAG configurations for improve…
hiroyukiiseo-hue 0197264
Add SafeEvalVisitor class for safe AST evaluation of dataset expressions
hiroyukiiseo-hue db1d089
Add unit tests for SafeEvalVisitor to validate AST evaluation
hiroyukiiseo-hue 7ed2a53
Add functions to extract dataset and storage names from expressions
hiroyukiiseo-hue e905f5f
Refactor condition evaluation methods in DagBuilder for improved safe…
hiroyukiiseo-hue 6958e24
Lint
hiroyukiiseo-hue 10150bb
Update __all__ in dagfactory and adjust expected output for invalid d…
hiroyukiiseo-hue cca2b54
Remove unsupported unary operation handling from SafeEvalVisitor
hiroyukiiseo-hue cf7df81
Fix formatting in __all__ declaration in dagfactory
hiroyukiiseo-hue 4ecb2b6
Refactor dataset handling in DagBuilder to improve clarity and introd…
hiroyukiiseo-hue 574b73a
Merge branch 'main' into feat/enable_schedule_dataset_condition
ErickSeo 5955f18
Merge branch 'main' into feat/enable_schedule_dataset_condition
ErickSeo ac83b56
Merge branch 'main' into feat/enable_schedule_dataset_condition
tatiana fb33b67
Merge branch 'main' into feat/enable_schedule_dataset_condition
tatiana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import ast | ||
|
|
||
|
|
||
| class SafeEvalVisitor(ast.NodeVisitor): | ||
| def __init__(self, dataset_map): | ||
| self.dataset_map = dataset_map | ||
|
|
||
| def evaluate(self, tree): | ||
| return self.visit(tree) | ||
|
|
||
| def visit_Expression(self, node): | ||
| return self.visit(node.body) | ||
|
|
||
| def visit_BinOp(self, node): | ||
| left = self.visit(node.left) | ||
| right = self.visit(node.right) | ||
|
|
||
| if isinstance(node.op, ast.BitAnd): | ||
| return left & right | ||
| elif isinstance(node.op, ast.BitOr): | ||
| return left | right | ||
| else: | ||
| raise ValueError(f"Unsupported binary operation: {type(node.op).__name__}") | ||
|
|
||
| def visit_Name(self, node): | ||
| if node.id in self.dataset_map: | ||
| return self.dataset_map[node.id] | ||
| raise NameError(f"Undefined variable: {node.id}") | ||
|
|
||
| def visit_Constant(self, node): | ||
| return node.value | ||
|
|
||
| def generic_visit(self, node): | ||
| raise ValueError(f"Unsupported syntax: {type(node).__name__}") |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.