-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into pdrm/08-22-_docs-beta_update_gh_action
- Loading branch information
Showing
10 changed files
with
770 additions
and
212 deletions.
There are no files selected for viewing
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
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
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
58 changes: 48 additions & 10 deletions
58
examples/experimental/dagster-airlift/dagster_airlift/core/utils.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,61 @@ | ||
from typing import Optional | ||
|
||
from dagster import AssetsDefinition | ||
from dagster import ( | ||
AssetsDefinition, | ||
_check as check, | ||
) | ||
|
||
MIGRATED_TAG = "airlift/task_migrated" | ||
DAG_ID_TAG = "airlift/dag_id" | ||
TASK_ID_TAG = "airlift/task_id" | ||
|
||
|
||
def get_task_id_from_asset(assets_def: AssetsDefinition) -> Optional[str]: | ||
if assets_def.node_def.tags and "airlift/task_id" in assets_def.node_def.tags: | ||
return assets_def.node_def.tags["airlift/task_id"] | ||
if len(assets_def.node_def.name.split("__")) == 2: | ||
return assets_def.node_def.name.split("__")[1] | ||
return None | ||
return _get_prop_from_asset(assets_def, TASK_ID_TAG, 1) | ||
|
||
|
||
def get_dag_id_from_asset(assets_def: AssetsDefinition) -> Optional[str]: | ||
if assets_def.node_def.tags and "airlift/dag_id" in assets_def.node_def.tags: | ||
return assets_def.node_def.tags["airlift/dag_id"] | ||
return _get_prop_from_asset(assets_def, DAG_ID_TAG, 0) | ||
|
||
|
||
def _get_prop_from_asset( | ||
assets_def: AssetsDefinition, prop_tag: str, position: int | ||
) -> Optional[str]: | ||
prop_from_tags = None | ||
if any(prop_tag in spec.tags for spec in assets_def.specs): | ||
prop = None | ||
for spec in assets_def.specs: | ||
if prop is None: | ||
prop = spec.tags[prop_tag] | ||
else: | ||
if spec.tags.get(prop_tag) is None: | ||
check.failed( | ||
f"Missing {prop_tag} tag in spec {spec.key} for {assets_def.node_def.name}" | ||
) | ||
check.invariant( | ||
prop == spec.tags[prop_tag], | ||
f"Task ID mismatch within same AssetsDefinition: {prop} != {spec.tags[prop_tag]}", | ||
) | ||
prop_from_tags = prop | ||
prop_from_op_tags = None | ||
if assets_def.node_def.tags and prop_tag in assets_def.node_def.tags: | ||
prop_from_op_tags = assets_def.node_def.tags[prop_tag] | ||
prop_from_name = None | ||
if len(assets_def.node_def.name.split("__")) == 2: | ||
return assets_def.node_def.name.split("__")[0] | ||
return None | ||
prop_from_name = assets_def.node_def.name.split("__")[position] | ||
if prop_from_tags and prop_from_op_tags: | ||
check.invariant( | ||
prop_from_tags == prop_from_op_tags, | ||
f"ID mismatch between asset tags and op tags: {prop_from_tags} != {prop_from_op_tags}", | ||
) | ||
if prop_from_tags and prop_from_name: | ||
check.invariant( | ||
prop_from_tags == prop_from_name, | ||
f"ID mismatch between tags and name: {prop_from_tags} != {prop_from_name}", | ||
) | ||
if prop_from_op_tags and prop_from_name: | ||
check.invariant( | ||
prop_from_op_tags == prop_from_name, | ||
f"ID mismatch between op tags and name: {prop_from_op_tags} != {prop_from_name}", | ||
) | ||
return prop_from_tags or prop_from_op_tags or prop_from_name |
188 changes: 0 additions & 188 deletions
188
...ples/experimental/dagster-airlift/dagster_airlift_tests/integration_tests/test_peering.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.