calm-agency-11588
07/18/2023, 1:56 PMacceptable-morning-73148
07/18/2023, 5:44 PMsearchAcrossEntities and provide the type GLOSSARY_TERM. I would then loop over the list of urns and retrieve details with a call to glossaryTerm. Something like this:
query {
searchAcrossEntities(input: {
start: 0,
count: 100,
query: "",
types: [GLOSSARY_TERM]
}
) {
searchResults {
entity {
urn,
__typename
}
}
}
}
Then do:
query($urn: String!) {
glossaryTerm (urn: $urn) {
properties {
name
}
}
}
You can also make the search more specific, by providing additional parameters like filters for example. See the documentation for more information.calm-agency-11588
07/19/2023, 3:35 PMacceptable-morning-73148
07/19/2023, 8:53 PMcalm-agency-11588
07/20/2023, 2:25 PMacceptable-morning-73148
07/20/2023, 2:58 PMcalm-agency-11588
07/20/2023, 8:32 PMpip install -U 'acryl-datahub[datahub-rest]' and tried this code using the rest emitter library -
from datahub.emitter.rest_emitter import DatahubRestEmitter
from datahub.metadata.schema_classes import GlobalSettingsInfoClass
# Create rest emitter
rest_emitter = DatahubRestEmitter(gms_server="<http://localhost:8080>")
# Fetch all glossary terms
glossary_terms = rest_emitter.get_glossary_terms()
# Print the glossary terms
for term in glossary_terms:
term_urn = term.entityUrn
term_name = term.aspect.name
term_definition = term.aspect.definition
print(f"Term URN: {term_urn}")
print(f"Term Name: {term_name}")
print(f"Term Definition: {term_definition}")
print("---")
The process failed with below error -
glossary_terms = rest_emitter.get_glossary_terms()
AttributeError: 'DataHubRestEmitter' object has no attribute 'get_glossary_terms'
I need your help with sample code that I can use to fetch the business glossaries both via Python Emitter and OPEN API ( CURL and Postman)calm-agency-11588
07/21/2023, 1:53 PMacceptable-morning-73148
07/26/2023, 3:14 PMfrom datahub.ingestion.graph.client import DataHubGraph, DataHubGraphConfig
datahub_graph = DataHubGraph(DataHubGraphConfig(server="<http://localhost:8080>"))
def get_business_glossary_terms():
graphQl = """
{
searchAcrossEntities(
input: {start: 0, count: 100, query: "", types: [GLOSSARY_TERM]}
) {
searchResults {
entity {
urn
... on GlossaryTerm {
properties {
name
}
}
}
}
}
}
"""
result = datahub_graph.execute_graphql(graphQl)
return map(
lambda x: x["entity"]["properties"]["name"],
result["searchAcrossEntities"]["searchResults"],
)
print(list(get_business_glossary_terms()))calm-agency-11588
07/26/2023, 4:24 PMacceptable-morning-73148
07/26/2023, 4:55 PMcalm-agency-11588
07/28/2023, 1:43 PM{
glossaryNode(urn: “urnliglossaryNode:<id>“) {
urn
type
exists
properties {
name
description
}
ownership {
...ownershipFields
}
parentNodes {
...parentNodesFields
}
children: relationships(
*input*: {types: ["IsPartOf"], direction: INCOMING, start: 0, count: 10000}
) {
total
relationships {
direction
entity {
type
urn
... *on* GlossaryNode {
...glossaryNode
}
... *on* GlossaryTerm {
...childGlossaryTerm
}
}
}
}
}
}
*fragment* ownershipFields *on* Ownership {
owners {
owner {
... *on* CorpUser {
urn
type
username
info {
active
displayName
title
email
}
properties {
active
displayName
title
email
}
}
... *on* CorpGroup {
urn
type
name
properties {
displayName
email
}
info {
displayName
email
admins {
urn
username
info {
active
displayName
title
email
}
}
members {
urn
username
info {
active
displayName
title
email
}
}
}
}
}
type
associatedUrn
}
lastModified {
time
}
}
*fragment* parentNodesFields *on* ParentNodesResult {
count
nodes {
urn
type
properties {
name
}
}
}
*fragment* glossaryNode *on* GlossaryNode {
urn
type
properties {
name
}
children: relationships(
*input*: {types: ["IsPartOf"], direction: INCOMING, start: 0, count: 10000}
) {
total
__typename
relationships {
direction
entity {
type
urn
... *on* GlossaryNode {
urn
type
properties {
name
}
children: relationships(
*input*: {types: ["IsPartOf"], direction: INCOMING, start: 0, count: 10000}
) {
total
__typename
relationships {
direction
entity {
type
urn
... *on* GlossaryNode {
urn
type
properties {
name
__typename
}
children: relationships(
*input*: {types: ["IsPartOf"], direction: INCOMING, start: 0, count: 10000}
) {
total
__typename
relationships {
direction
entity {
type
urn
... *on* GlossaryNode {
urn
type
properties {
name
__typename
}
children: relationships(
*input*: {types: ["IsPartOf"], direction: INCOMING, start: 0, count: 10000}
) {
total
relationships {
direction
entity {
type
urn
... *on* GlossaryNode {
urn
type
properties {
name
}
children: relationships(
*input*: {types: ["IsPartOf"], direction: INCOMING, start: 0, count: 10000}
) {
total
__typename
relationships {
direction
entity {
type
urn
... *on* GlossaryNode {
__typename
}
... *on* GlossaryTerm {
...childGlossaryTerm
__typename
}
__typename
}
__typename
}
}
__typename
__typename
}
... *on* GlossaryTerm {
...childGlossaryTerm
__typename
}
__typename
}
__typename
}
}
__typename
__typename
}
... *on* GlossaryTerm {
...childGlossaryTerm
__typename
}
__typename
}
__typename
}
}
__typename
__typename
}
... *on* GlossaryTerm {
...childGlossaryTerm
__typename
}
__typename
}
__typename
}
}
__typename
}
... *on* GlossaryTerm {
...childGlossaryTerm
__typename
}
__typename
}
__typename
}
}
__typename
}
*fragment* childGlossaryTerm *on* GlossaryTerm {
urn
type
name
hierarchicalName
properties {
name
__typename
}
institutionalMemory{
elements
{
label
url
}
}
__typename
}acceptable-morning-73148
07/28/2023, 10:22 PM