adorable-salesclerk-90917
01/04/2024, 6:05 PMgray-ocean-32209
01/09/2024, 8:16 AMadorable-salesclerk-90917
01/09/2024, 2:51 PMacceptable-morning-73148
01/10/2024, 12:05 PMdef create_tag(self, name: str) -> str:
tag_urn = make_tag_urn(name)
# check if the tag exists
query = (
"""query {
tag(urn: \""""
+ tag_urn
+ """\") {
properties {
name
}
}
}"""
)
exists = self.client.execute(query)
if exists["data"]["tag"]["properties"] is None:
# tag doesn't exist, create it
mutation = (
"""mutation {
createTag(input: {id: \""""
+ name
+ """\", name: \""""
+ name
+ """\"})
}
"""
)
json = self.client.execute(query=mutation)
tag_urn = json["data"]["createTag"]
print(f"tag {tag_urn} created.")
return tag_urn
else:
return tag_urn
def tag_dataset(self, dataset_urn, tag_name) -> bool:
tag_urn = make_tag_urn(tag_name)
mutation = (
"""mutation {
addTag(input: {tagUrn: \""""
+ tag_urn
+ """\", resourceUrn: \""""
+ dataset_urn
+ """\"})
}
"""
)
json = self.client.execute(query=mutation)
return bool(json["data"]["addTag"])
rich-barista-93413
02/06/2024, 7:11 PM