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

[Feature Request] add "id_conflict_policy" arg for "execute_child_workflow" #587

Closed
johnny-smitherson opened this issue Jul 18, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@johnny-smitherson
Copy link

Is your feature request related to a problem? Please describe.

The new id_conflict_policy arg is very useful to reduce the amount of try/except one has to use in workflows. But it doesn't work for start_child_workflow(...) / execute_child_workflow.

Describe the solution you'd like

await workflow.execute_child_workflow(
    ...,
    id_conflict_policy=WorkflowIDConflictPolicy.USE_EXISTING,  # master branch only
)

---> TypeError: execute_child_workflow() got an unexpected keyword argument 'id_conflict_policy'

Additional context

Is this a limitation of the API (and requires additions there too), or just the python library?

API PR was here temporalio/api#359

If filed in wrong place, please move issue

Thank you!

@johnny-smitherson johnny-smitherson added the enhancement New feature or request label Jul 18, 2024
@cretz
Copy link
Member

cretz commented Jul 18, 2024

Is this a limitation of the API (and requires additions there too)

This is a limitation of the API

If filed in wrong place, please move issue

We can move to server repo, but there is a question of whether this is needed.

As a workflow author, you are the starter of the child workflows in your workflow and the listener of their completion states. Therefore you can perform whatever conflict resolution you'd like instead of the limited set offered by this value. We recommend using WorkflowAlreadyStartedError and consider it a healthy use of try/except. You can wrap it in a helper if needed, but I am not sure we want to do this helper (this is shown as an error in history, and we think it's important for code and history to be clear on these things).

@johnny-smitherson
Copy link
Author

Ah yes I see - for child tasks i can do

try:
        return await workflow.execute_child_workflow(
            ...
            id=the_id
        )
    except WorkflowAlreadyStartedError:
        handle = await workflow.get_external_workflow_handle(the_id)
        return await handle.result()

And that's more or less USE_EXISTING of the new param

or instead of handle.result(), I would terminate and restart to obtain the other behaviors of the param

Thanks!

@cretz cretz closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2024
@cretz
Copy link
Member

cretz commented Jul 18, 2024

get_external_workflow_handle does not return a handle with result. Getting a non-child result of a workflow from another workflow directly is not supported. Rather, if that already exists as a child, it means you started it some other time in your workflow. You can store that child handle on the class and access its result. If you need the result of a workflow that was not started as a child, you may have to break out into an activity and use the Temporal client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants