Is there a way to easily extract the last heartbeat information of the activity using workflow handle in Python API?

I created an activity that does:

activity.heartbeat(int_progress)

and I have another piece of code:

describe_result = await workflow_handle.describe()

Now I can see that, the string representation of describe_result clearly contains the progress of my interests, but I can not find a way to extract it. Sure, I can parse the string, but that would be a hack.

Any suggestion?

describe_result there is WorkflowExecutionDescription which is a wrapper around our raw protobuf API value with some friendly properties from it. We have not exposed pending activities (yet?), but you can access them via the raw_description proto. So for the first pending activity’s heartbeat details, you could describe_result.raw_description.pending_activities[0].heartbeat_details. This is a raw payloads wrapper value, which you can pass to default converter, e.g. for the first detail: (await DataConverter.default.decode_wrapper(heartbeat_details, [int]))[0].

This is all fairly advanced low-level API. Note that this only applies to pending activities. Once an activity is complete it will not contain heartbeat details.

1 Like

I see, thanks, this does works and solve my problem for now.

I believe heartbeats are very important, they are the only programmatic way to know if a long running activity may be still behaving or was just hanging for some reason. I would certainly suggest exposing pending actives functionality to be added to the future!