Get the job instance details

I am using python client
I am trying to find the details of the instance the worker is supposed to process

Looking at a Java example - I find the following methods
job.getWorkflowInstanceKey()
Instant.ofEpochMilli(job.getDeadline())
job.getCustomHeaders()
job.getVariables()

what are the equivalent python functions - how can I get the properties of the instance

Hi @S.Gopalakrishnan4, it looks like the job variable is a dictionary, from the Python client README. Here is the relevant part of the example from there:

 for response in activate_jobs_response:
        for job in response.jobs:
            try:
                print(job.variables)
                stub.CompleteJob(gateway_pb2.CompleteJobRequest(jobKey=job.key, variables=json.dumps({})))
                logging.info('Job Completed')
            except Exception as e:
                stub.FailJob(gateway_pb2.FailJobRequest(jobKey=job.key))
                logging.info('Job Failed {}'.format(e))

@gizmo84 is the Python client author.

1 Like

@jwulf - Thank you
I was using a different blog post to create the package - not using the standard zeebe_grpc available using pip

Yes, I am able to get all the variables now

Hi @S.Gopalakrishnan4,

Please have a look at this example: https://gitlab.com/stephane.ludwig/zeebe_worker/-/blob/master/zeebe_worker.py

All the relevant job details are stored in the “job” variable. For example:

job.key
job.variables
job.customHeaders

Please note that zeebe-grpc is only a very low-level client. I’m working on a high level Client / Worker similar to the node / java client.

@gizmo84 - I will look into this one too
Thank you