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

fix(ingestion) containers: Adding platform instance to container keys #4279

Merged

Conversation

treff7es
Copy link
Contributor

@treff7es treff7es commented Mar 1, 2022

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable)

@github-actions
Copy link

github-actions bot commented Mar 1, 2022

Unit Test Results (metadata ingestion)

       5 files  ±0         5 suites  ±0   46m 27s ⏱️ - 2m 33s
   363 tests +1     363 ✔️ +1    0 💤 ±0  0 ±0 
1 662 runs  +5  1 624 ✔️ +5  38 💤 ±0  0 ±0 

Results for commit 25b4349. ± Comparison against base commit 2d10d99.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Mar 1, 2022

Unit Test Results (build & test)

  92 files  ±0    92 suites  ±0   12m 57s ⏱️ - 3m 12s
673 tests ±0  613 ✔️  - 1  59 💤 ±0  1 +1 

For more details on these failures, see this check.

Results for commit 25b4349. ± Comparison against base commit 2d10d99.

♻️ This comment has been updated with latest results.

@@ -13,18 +13,35 @@ def test_guid_generator():

def test_guid_generator_with_empty_instance():
key = builder.SchemaKey(
database="test", schema="Test", platform="mysql", instance=None
database="test",
Copy link
Contributor

Choose a reason for hiding this comment

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

There are some instance="PROD" in line 7 and 42 that may be semantically misleading. I would suggest to update them accordingly too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks I renamed it to make it clearer a bit

@treff7es treff7es force-pushed the platform_instance_container_id_fix branch from 74e8ad4 to f4caaf3 Compare March 4, 2022 09:09
@treff7es treff7es changed the title [draft] Adding platform instance to container keys fix(ingestion) containers: Adding platform instance to container keys Mar 4, 2022
@treff7es treff7es force-pushed the platform_instance_container_id_fix branch from 0d7f822 to 7693e81 Compare March 9, 2022 19:10
# Find container ids need to be migrated
container_id_map: Dict[str, str] = {}
# Get all the containers need to be migrated
containers = get_container_for_migration(env)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: maybe name this get_containers_for_migration


entity_type = _get_type_from_urn(target_urn)
relationshipType = relationship["type"]
aspect_name = migration_utils.get_aspect_name_from_relationship_type_and_entity(
Copy link
Collaborator

Choose a reason for hiding this comment

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

this method is very suspicious :)

"containerKey",
"container",
"domains",
"containerProperties" "editableContainerProperties",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should these be separated by newline?

"mlfeature": "mlFeatureProperties",
"mlprimarykey": "mlPrimaryKeyProperties",
},
"IsPartOf": {"container": "container", "dataset": "container"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

dashboard and chart can also technically have container aspect, btw

if entity_type.lower() == "mlprimarykey":
return "mlPrimaryKeyProperties"
aspect_map = {
"Produces": {"datajob": "dataJobInputOutput"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems a bit difficult to maintain.

It also does not account for cases where the same edge type can be between multiple source dest nodes ... For examples "glossaryTerm ASSOCIATED_WITH dataset" and "tag ASSOCIATED_WITH dataset"... cc @gabe-lyons - maybe a reason not to do this?

new_urn: str,
) -> DictWrapper:
if aspect_name == "dataJobInputOutput":
class UrnListModifier:
Copy link
Collaborator

Choose a reason for hiding this comment

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

just curious - why is this better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Flake8 is complaining about the high complexity of the method because of the too many if branches.

if aspect_names is not None:
for a in aspect_names:
if a in aspect_map:
aspect_value = aspect_map[a]
assert isinstance(aspect_value, DictWrapper)
new_mcp = MetadataChangeProposalWrapper(
entityUrn=dst_urn,
entityType="dataset",
entityType=entity_type,
Copy link
Collaborator

Choose a reason for hiding this comment

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

much better :)

)


def get_outgoing_relationships_dataset(urn: str) -> Iterable[Dict]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

suffixing in _dataset is confusing, given that "dataset" also means something special to datahub :) Consider renaming this to something that won't easily be confused

class SchemaKey(DatabaseKey):
schema: str
db_schema: str = Field(alias="schema")
Copy link
Collaborator

Choose a reason for hiding this comment

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

why change to db_schema?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

schema is an internal property of Pydantic and you can't use it. :(
That's why I had to set an alias to workaround this.

@@ -534,7 +534,7 @@ def gen_database_key(self, database: str) -> DatabaseKey:
return DatabaseKey(
database=database,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't support instance in glue?

environment: Optional[str] = None

@root_validator(pre=True)
def check_instance_environment(cls, values: Dict[str, Any]) -> Dict[str, Any]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay this clears things up. Never an env inside..

Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes it a bit confusing for folks trying to understand how container keys are generated. I would naturally think the contract is that this object is turned into a dict then hashed, but really theres some logic inside.

@jjoyce0510 jjoyce0510 merged commit f557b2c into datahub-project:master Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants