hatchet-dev / hatchet-python

Hatchet Python SDK for Interacting with the Hatchet Engine
23 stars 12 forks source link

Workflow Status Capture Failure after Upgrade to v0.27.0 with Log Capture #57

Closed ArthurMor4is closed 1 month ago

ArthurMor4is commented 3 months ago

Context:

I'm using the following step to check the status of new workflows:

@hatchet.step(parents=["features"])
async def wait_for_children(
    self, context: Context
):
    document_id = context.step_output("features")["document_id"]
    child_workflow_run_ids = context.step_output("features")["child_workflow_run_ids"]

    root_logger.info(f"Will wait for {len(child_workflow_run_ids)} child workflow runs to finish")
    results = []
    for id in child_workflow_run_ids:
        results.append(await hatchet.client.admin.get_workflow_run(id).result())

    is_done = all(result["finish_process_document"]["done"] is True for result in results)

    if not is_done:
        root_logger.error("Some child workflows could not finish.")
        raise Exception("Some child workflows could not finish.")

    return {"document_id": document_id, "child_workflow_run_ids": child_workflow_run_ids}

I was able to capture workflow statuses correctly using version 0.26.4 of the library. However, I tried to update to version 0.27.0 and use log capture according to the documentation at this link: https://docs.hatchet.run/sdks/python-sdk/logging

From then on, I can no longer capture the statuses correctly. I think the error in question is related to this commit: https://github.com/hatchet-dev/hatchet-python/commit/f42bcfbba2a7124e3ec8d1c1544c7c08bdc6b499

All other steps in my workflow are synchronous

Bug error:

image

abelanger5 commented 3 months ago

Hey @ArthurMor4is, it looks like this is caused by a step returning something that is a coroutine. At first glance, this doesn't look related to logging, but could be due to some recent changes we made to the return values of spawn_workflow and run_workflow.

Is there any chance you could share the relevant code for the features step? Or share how you're calling spawn_workflow?