2021-11-18 23:30:25 -08:00
|
|
|
import datahub.emitter.mce_builder as builder
|
|
|
|
from datahub.emitter.mcp import MetadataChangeProposalWrapper
|
|
|
|
from datahub.emitter.rest_emitter import DatahubRestEmitter
|
|
|
|
from datahub.metadata.com.linkedin.pegasus2avro.datajob import DataJobInfoClass
|
2022-12-30 01:26:47 -05:00
|
|
|
from datahub.metadata.schema_classes import DataFlowInfoClass
|
2021-11-18 23:30:25 -08:00
|
|
|
|
|
|
|
# Construct the DataJobInfo aspect with the job -> flow lineage.
|
|
|
|
dataflow_urn = builder.make_data_flow_urn(
|
2022-04-13 08:19:39 +02:00
|
|
|
orchestrator="airflow", flow_id="flow_old_api", cluster="prod"
|
|
|
|
)
|
|
|
|
|
|
|
|
dataflow_info = DataFlowInfoClass(name="LowLevelApiFlow")
|
|
|
|
|
|
|
|
dataflow_info_mcp = MetadataChangeProposalWrapper(
|
|
|
|
entityUrn=dataflow_urn,
|
|
|
|
aspect=dataflow_info,
|
2021-11-18 23:30:25 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
datajob_info = DataJobInfoClass(name="My Job 1", type="AIRFLOW", flowUrn=dataflow_urn)
|
|
|
|
|
|
|
|
# Construct a MetadataChangeProposalWrapper object with the DataJobInfo aspect.
|
|
|
|
# NOTE: This will overwrite all of the existing dataJobInfo aspect information associated with this job.
|
2022-04-13 08:19:39 +02:00
|
|
|
datajob_info_mcp = MetadataChangeProposalWrapper(
|
2021-11-18 23:30:25 -08:00
|
|
|
entityUrn=builder.make_data_job_urn(
|
2022-04-13 08:19:39 +02:00
|
|
|
orchestrator="airflow", flow_id="flow_old_api", job_id="job1", cluster="prod"
|
2021-11-18 23:30:25 -08:00
|
|
|
),
|
|
|
|
aspect=datajob_info,
|
|
|
|
)
|
|
|
|
|
|
|
|
# Create an emitter to the GMS REST API.
|
|
|
|
emitter = DatahubRestEmitter("http://localhost:8080")
|
|
|
|
|
|
|
|
# Emit metadata!
|
2022-04-13 08:19:39 +02:00
|
|
|
emitter.emit_mcp(dataflow_info_mcp)
|
|
|
|
emitter.emit_mcp(datajob_info_mcp)
|