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 optional config for ownership type in ownership transforms #3159

Merged

Conversation

sgomezvillamor
Copy link
Contributor

@sgomezvillamor sgomezvillamor commented Aug 25, 2021

This is adding the ability to specify the ownership type in the ownership transformations. DATAOWNER is the default value if not given or if an unexpected value is given.

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)

@sgomezvillamor
Copy link
Contributor Author

@shirshanka : I'm not a python expert, so I would appreciate your feedback on this (code, naming, etc) before going on and update docs. Thanks!

@sgomezvillamor sgomezvillamor marked this pull request as ready for review August 26, 2021 15:48
@@ -112,6 +113,21 @@ def make_ml_model_group_urn(platform: str, group_name: str, env: str) -> str:
)


def check_ownership_type(ownership_type: Optional[str]) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

Name of the function is somewhat misleading. Looking at a check_* function I would assume a boolean return type. Maybe use is_valid_ownership_type and actually return a boolean? That boolean can be used in the transformer.

return ownership_type
else:
logger.warning(f"invalid ownership type value: {ownership_type}")
return OwnershipTypeClass.DATAOWNER
Copy link
Contributor

Choose a reason for hiding this comment

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

Having a default value here can cause confusion when using this function.

@@ -60,14 +59,18 @@ def transform_one(self, mce: MetadataChangeEventClass) -> MetadataChangeEventCla
class SimpleDatasetOwnershipConfig(ConfigModel):
owner_urns: List[str]
default_actor: str = builder.make_user_urn("etl")
ownership_type: Optional[str] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be better to add that default value here instead of None. This will keep things backward compatible which seemed to be your intention by sending that value back

@sgomezvillamor
Copy link
Contributor Author

Thanks @aseembansal-gogo for the review. I have refactored the code, mainly moving default value close to the transformer itself.

My biggest concern now is on having the list of valid ownership types for the validation because it needs to be updated when new types are added. Alternatively I could skip that validation in the transformer and just let the MCE event fail later, in the GMS API. WDYT?

@sgomezvillamor
Copy link
Contributor Author

@aseembansal-gogo @shirshanka may I ask you to review again after last update? thanks

Copy link
Contributor

@shirshanka shirshanka left a comment

Choose a reason for hiding this comment

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

This LGTM.

I think there could be a more sophisticated version of this config like, which we can do in a follow up PR. We also would need to auto-upgrade old style config to new style in that case.

owners: 
      users:
           - id: jdoe
              type: DATAOWNER
            - id: bsmith
               type: DEVELOPER
      groups:
             -id: security
               type: STAKEHOLDER

@shirshanka shirshanka merged commit 9e28423 into datahub-project:master Sep 2, 2021
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.

3 participants