forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docs): Add improvements in examples for PATCH documentation (data…
…hub-project#12165) Co-authored-by: John Joyce <[email protected]> Co-authored-by: John Joyce <[email protected]>
- Loading branch information
1 parent
89acda6
commit 9031b49
Showing
14 changed files
with
321 additions
and
148 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
19 changes: 19 additions & 0 deletions
19
metadata-ingestion/examples/library/dataset_add_custom_properties_patch.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from datahub.emitter.mce_builder import make_dataset_urn | ||
from datahub.ingestion.graph.client import DataHubGraph, DataHubGraphConfig | ||
from datahub.specific.dataset import DatasetPatchBuilder | ||
|
||
# Create DataHub Client | ||
datahub_client = DataHubGraph(DataHubGraphConfig(server="http://localhost:8080")) | ||
|
||
# Create Dataset URN | ||
dataset_urn = make_dataset_urn(platform="hive", name="fct_users_created", env="PROD") | ||
|
||
# Create Dataset Patch to Add Custom Properties | ||
patch_builder = DatasetPatchBuilder(dataset_urn) | ||
patch_builder.add_custom_property("cluster_name", "datahubproject.acryl.io") | ||
patch_builder.add_custom_property("retention_time", "2 years") | ||
patch_mcps = patch_builder.build() | ||
|
||
# Emit Dataset Patch | ||
for patch_mcp in patch_mcps: | ||
datahub_client.emit(patch_mcp) |
22 changes: 22 additions & 0 deletions
22
metadata-ingestion/examples/library/dataset_add_glossary_term_patch.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from datahub.emitter.mce_builder import make_dataset_urn, make_term_urn | ||
from datahub.ingestion.graph.client import DataHubGraph, DataHubGraphConfig | ||
from datahub.metadata.schema_classes import GlossaryTermAssociationClass | ||
from datahub.specific.dataset import DatasetPatchBuilder | ||
|
||
# Create DataHub Client | ||
datahub_client = DataHubGraph(DataHubGraphConfig(server="http://localhost:8080")) | ||
|
||
# Create Dataset URN | ||
dataset_urn = make_dataset_urn( | ||
platform="snowflake", name="fct_users_created", env="PROD" | ||
) | ||
|
||
# Create Dataset Patch to Add + Remove Term for 'profile_id' column | ||
patch_builder = DatasetPatchBuilder(dataset_urn) | ||
patch_builder.add_term(GlossaryTermAssociationClass(make_term_urn("term-to-add-id"))) | ||
patch_builder.remove_term(make_term_urn("term-to-remove-id")) | ||
patch_mcps = patch_builder.build() | ||
|
||
# Emit Dataset Patch | ||
for patch_mcp in patch_mcps: | ||
datahub_client.emit(patch_mcp) |
24 changes: 24 additions & 0 deletions
24
metadata-ingestion/examples/library/dataset_add_owner_patch.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from datahub.emitter.mce_builder import make_dataset_urn, make_group_urn, make_user_urn | ||
from datahub.ingestion.graph.client import DataHubGraph, DataHubGraphConfig | ||
from datahub.metadata.schema_classes import OwnerClass, OwnershipTypeClass | ||
from datahub.specific.dataset import DatasetPatchBuilder | ||
|
||
# Create DataHub Client | ||
datahub_client = DataHubGraph(DataHubGraphConfig(server="http://localhost:8080")) | ||
|
||
# Create Dataset URN | ||
dataset_urn = make_dataset_urn( | ||
platform="snowflake", name="fct_users_created", env="PROD" | ||
) | ||
|
||
# Create Dataset Patch to Add + Remove Owners | ||
patch_builder = DatasetPatchBuilder(dataset_urn) | ||
patch_builder.add_owner( | ||
OwnerClass(make_user_urn("user-to-add-id"), OwnershipTypeClass.TECHNICAL_OWNER) | ||
) | ||
patch_builder.remove_owner(make_group_urn("group-to-remove-id")) | ||
patch_mcps = patch_builder.build() | ||
|
||
# Emit Dataset Patch | ||
for patch_mcp in patch_mcps: | ||
datahub_client.emit(patch_mcp) |
44 changes: 0 additions & 44 deletions
44
metadata-ingestion/examples/library/dataset_add_properties.py
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
metadata-ingestion/examples/library/dataset_add_remove_custom_properties_patch.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from datahub.emitter.mce_builder import make_dataset_urn | ||
from datahub.ingestion.graph.client import DataHubGraph, DataHubGraphConfig | ||
from datahub.specific.dataset import DatasetPatchBuilder | ||
|
||
# Create DataHub Client | ||
datahub_client = DataHubGraph(DataHubGraphConfig(server="http://localhost:8080")) | ||
|
||
# Create Dataset URN | ||
dataset_urn = make_dataset_urn(platform="hive", name="fct_users_created", env="PROD") | ||
|
||
# Create Dataset Patch to Add + Remove Custom Properties | ||
patch_builder = DatasetPatchBuilder(dataset_urn) | ||
patch_builder.add_custom_property("cluster_name", "datahubproject.acryl.io") | ||
patch_builder.remove_custom_property("retention_time") | ||
patch_mcps = patch_builder.build() | ||
|
||
# Emit Dataset Patch | ||
for patch_mcp in patch_mcps: | ||
datahub_client.emit(patch_mcp) |
46 changes: 0 additions & 46 deletions
46
metadata-ingestion/examples/library/dataset_add_remove_properties.py
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
metadata-ingestion/examples/library/dataset_add_structured_properties.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.