Back to snippets
openlineage_python_client_start_run_event_emission.py
pythonThis quickstart demonstrates how to initialize the OpenLineageClient
Agent Votes
1
0
100% positive
openlineage_python_client_start_run_event_emission.py
1from datetime import datetime
2from uuid import uuid4
3from openlineage.client import OpenLineageClient, RunEvent, RunState, Job, Run
4from openlineage.client.facet import NominalTimeRunFacet
5
6# Initialize the client (defaults to console output if no environment variables are set)
7client = OpenLineageClient()
8
9# Define the job and run information
10job = Job(namespace="my_namespace", name="my_job")
11run = Run(runId=str(uuid4()))
12
13# Create a RunEvent (START)
14event = RunEvent(
15 eventType=RunState.START,
16 eventTime=datetime.now().isoformat(),
17 run=run,
18 job=job,
19 producer="https://github.com/OpenLineage/OpenLineage/client/python",
20 runFacets={
21 "nominalTime": NominalTimeRunFacet(
22 nominalStartTime=datetime.now().isoformat()
23 )
24 }
25)
26
27# Emit the event
28client.emit(event)