Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change call_child_workflow to pass correct wf name to durabletask worker #616

Merged
merged 5 commits into from
Oct 31, 2023
Merged

Conversation

bkc
Copy link
Contributor

@bkc bkc commented Oct 11, 2023

Description

durabletask.worker uses orchestrator.__name__ here

but when dapr_workflow_context wraps the real workflow function in wf, the correct orchestrator name is lost.

This bug results in the following exception:

durabletask.task.TaskFailedError: Sub-orchestration task #1 failed: A 'wf' orchestrator was not registered.

when called as

raw_download_result = yield ctx.call_child_workflow(
            workflow=files_com_wf.files_com_download_file_wf,
            input=path,
            instance_id=None,
        )

This proposed fix is not pretty, but it works.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #615

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

There aren't any existing tests or even any examples that use call_child_workflow, I'm sorry I do not have time to write tests or documentation at this time.

durabletask.worker uses orchestrator.__name__ at https://github.com/microsoft/durabletask-python/blob/c9990973a7cc18b2db1219d129961cede9eb3948/durabletask/worker.py#L387  

but when dapr_workflow_context wraps the real workflow function in `wf`, the correct orchestrator name is lost.

This bug results in an exception:

durabletask.task.TaskFailedError: Sub-orchestration task #1 failed: A 'wf' orchestrator was not registered.

This proposed fix is not pretty, but it works.

Signed-off-by: Brad Clements <bkc@murkworks.com>
@bkc bkc requested review from a team as code owners October 11, 2023 22:05
@@ -61,6 +61,7 @@ def call_child_workflow(self, workflow: Workflow, *,
def wf(ctx: task.OrchestrationContext, inp: TInput):
daprWfContext = DaprWorkflowContext(ctx)
return workflow(daprWfContext, inp)
wf.__name__ = workflow.__name__ # copy workflow name so durabletask.worker can find the orchestrator in its registry
return self.__obj.call_sub_orchestrator(wf, input=input, instance_id=instance_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While hacky, this feels like the right fix given the current limitations of the durabletask-python library. Ideally we add a parameter to call_sub_orchestrator that allows overriding the name so that callers don't need to be aware of the internal implementation details.

@DeepanshuA thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this and you can consider a better solution in a future release.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment line is too long. Please see Python style guide ;)

berndverst
berndverst previously approved these changes Oct 31, 2023
berndverst
berndverst previously approved these changes Oct 31, 2023
@berndverst berndverst merged commit 00937c6 into dapr:master Oct 31, 2023
7 of 11 checks passed
@yaron2 yaron2 added this to the v1.14 milestone Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

call_child_workflow breaks due to orchestrator name being lost
4 participants