:wave: I'm getting the error `AvroException: ('Dat...
# troubleshoot
c
👋 I'm getting the error
AvroException: ('Datum union type not in schema: %s', None)
when running
graph.get_aspect_v2(entity_urn=urn, aspect="dataJobInfo", aspect_type=DataJobInfoClass)
I see someone brought this up in the past but not sure if it was ever resolved. I'm trying to write a job that updates the datajobInfo aspect of a data job instead of overwriting it, so I need to access this aspect. Any help would be appreciated! cc @big-carpet-38439 who looked at this issue before
✅ 1
b
hey Divya! are you trying to access the aspect in the same way as the person you linked to? as in you're trying to use the python SDK and it's not working?
c
I'm trying to access the aspect from an Airflow job, doing something like this for the setup:
Copy code
gms_endpoint = "<http://datahub-gms.service.envoy:10080>"
graph = DataHubGraph(DatahubClientConfig(server=gms_endpoint)) 
 urn = "..."
info =  graph.get_aspect_v2(entity_urn=urn, aspect="dataJobInfo", aspect_type=DataJobInfoClass)
b
are you having issues with getting aspects like this with any other aspect type? also tbh I'm not the expert on our python SDK, but can you try getting it without the
aspect="dataJobInfo"
piece? so just
info =  graph.get_aspect_v2(entity_urn=urn, aspect_type=DataJobInfoClass)
c
The issue is only with this specific aspect, I'm able to retrieve the other ones just fine (such as glossary terms)
Copy code
get_aspect_v2() missing 1 required positional argument: 'aspect'
b
ahh it's the v2 version sorry I didn't actually realize that
hmm I'm going to try this myself and see if I can get any extra help here
c
I get the same error with
get_aspect()
as well
thank you!
b
okay good to know about
get_aspect()
as well!
m
@calm-balloon-31412: try this
Copy code
from datahub.metadata.schema_classes import DataJobInfoClass
from datahub.ingestion.graph.client import DataHubGraph, DataHubGraphConfig


graph = DataHubGraph(DataHubGraphConfig())


datajob = graph.get_aspect(entity_urn="urn:li:dataJob:(urn:li:dataFlow:(airflow,dag_abc,PROD),task_123)", aspect_type=DataJobInfoClass)

print(datajob)
if you're still facing this error, there is likely a mismatch between the cli version (model) and the server version (model)
c
Maybe because we are on an older version, but I don't have
DataHubGraphConfig
in
datahub.ingestion.graph.client
m
yeah that shouldn't be causing a problem
the main issue is probably your client is compiled against a version of the model that doesn't have an enum value ... while the server is sending it back
upgrading the client should solve this
another workaround would be to the
cli_utils
methods
here is what that would look like:
Copy code
from datahub.cli.cli_utils import get_aspects_for_entity
from datahub.cli.cli_utils import ENV_METADATA_HOST_URL
import os

def set_host_url(host_url: str):
    os.environ.set(ENV_METADATA_HOST_URL, host_url)

set_host_url("<http://localhost:8080>")
aspect_dict = get_aspects_for_entity(entity_urn="urn:li:dataJob:(urn:li:dataFlow:(airflow,dag_abc,PROD),task_123)", aspects=["dataJobInfo"], typed=False)
print(aspect_dict)
you would get an untyped dictionary back
c
oh cool that worked!!
thanks so much 🙂