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

Start orphan child workflow from workflow #5777

Open
sytranvn opened this issue Apr 23, 2024 · 2 comments
Open

Start orphan child workflow from workflow #5777

sytranvn opened this issue Apr 23, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@sytranvn
Copy link

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

Ability to start new workflow from other workflow. But the new workflow's lifeftime does not depends on the other.

ParentWorkflow ------------------------------------------------------x
                 |                  |    |                       |
                 ---ChildWorkflow----    ---- other activities ---
                                   |
                                   --- WrapupWorkflow --x

As in this diagram, after the ChildWorkflow complete its job, we want to return the result immediately to ParentWorkflow. The WrapupWorkflow only start the next day, and its result doesn't matter to the ParentWorkflow. Currently child workflow and activity lifetime depends on workflow. So I have to add additional steps to call an activity, which connects to Client and call start_workflow. Like this.

ParentWorkflow -----------------------------------------------------------------------------x
                 |                                         |  |                       |
                 ---ChildWorkflow--------------------------|   ---- other activities --
                                  |                        |        
                                  -- start_wrapup_activity-
                                   |
                                   --- client.start_workflow(WrapupWorkflow) --x

Describe the solution you'd like
Support starting an orphan workflow from inside workflow and forget it.

   workflow.start_orphan_workflow(
        WrapupWorkflow.run,
        "your retry policy argument",
        delay_start=timedelta(days=1),
        id="your-workflow-id",
        task_queue="your-task-queue",
    )

This might not applicable to execute_workflow though.

@sytranvn sytranvn added the enhancement New feature or request label Apr 23, 2024
@stephanos
Copy link
Contributor

Hi @sytranvn! Could you take a look at https://docs.temporal.io/workflows#parent-close-policy - specifically Abandon - and let me know if that solves your problem?

@sytranvn
Copy link
Author

@stephanos , I use ABANDON as parameter for start_child_workflow. But the child is still terminated as soon as Parent completes. Here's the code https://github.com/sytranvn/abandon-child

Parent's events image
{
  "eventId": "1",
  "eventTime": "2024-04-29T01:53:39.274145300Z",
  "eventType": "WorkflowExecutionStarted",
  "version": "0",
  "taskId": "7342055",
  "workerMayIgnore": false,
  "workflowExecutionStartedEventAttributes": {
    "workflowType": {
      "name": "Parent"
    },
    "parentWorkflowNamespace": "",
    "parentWorkflowNamespaceId": "",
    "parentWorkflowExecution": null,
    "parentInitiatedEventId": "0",
    "taskQueue": {
      "name": "hello-activity-task-queue",
      "kind": "Normal",
      "normalName": ""
    },
    "input": null,
    "workflowExecutionTimeout": null,
    "workflowRunTimeout": null,
    "workflowTaskTimeout": "10s",
    "continuedExecutionRunId": "",
    "initiator": "Unspecified",
    "continuedFailure": null,
    "lastCompletionResult": null,
    "originalExecutionRunId": "218527ab-72a1-4602-8983-49652953e7ef",
    "identity": "87986@sytd",
    "firstExecutionRunId": "218527ab-72a1-4602-8983-49652953e7ef",
    "retryPolicy": null,
    "attempt": 1,
    "workflowExecutionExpirationTime": null,
    "cronSchedule": "",
    "firstWorkflowTaskBackoff": "0s",
    "memo": null,
    "searchAttributes": null,
    "prevAutoResetPoints": null,
    "header": null,
    "parentInitiatedEventVersion": "0",
    "workflowId": "hello-activity-workflow-id",
    "sourceVersionStamp": null
  }
}
Child's events Screenshot 2024-04-29 at 09 02 44 Screenshot 2024-04-29 at 09 01 59
{
  "eventId": "1",
  "eventTime": "2024-04-29T01:53:39.343533866Z",
  "eventType": "WorkflowExecutionStarted",
  "version": "0",
  "taskId": "7341866",
  "workerMayIgnore": false,
  "workflowExecutionStartedEventAttributes": {
    "workflowType": {
      "name": "Child"
    },
    "parentWorkflowNamespace": "default",
    "parentWorkflowNamespaceId": "143c04ed-6dba-4d45-b992-f9b71480ffcd",
    "parentWorkflowExecution": {
      "workflowId": "hello-activity-workflow-id",
      "runId": "218527ab-72a1-4602-8983-49652953e7ef"
    },
    "parentInitiatedEventId": "5",
    "taskQueue": {
      "name": "hello-activity-task-queue",
      "kind": "Normal",
      "normalName": ""
    },
    "input": null,
    "workflowExecutionTimeout": null,
    "workflowRunTimeout": "0s",
    "workflowTaskTimeout": "10s",
    "continuedExecutionRunId": "",
    "initiator": "Unspecified",
    "continuedFailure": null,
    "lastCompletionResult": null,
    "originalExecutionRunId": "63529741-0faa-4673-84b0-1099ac50fa29",
    "identity": "",
    "firstExecutionRunId": "63529741-0faa-4673-84b0-1099ac50fa29",
    "retryPolicy": null,
    "attempt": 1,
    "workflowExecutionExpirationTime": null,
    "cronSchedule": "",
    "firstWorkflowTaskBackoff": "0s",
    "memo": {
      "fields": {}
    },
    "searchAttributes": {
      "indexedFields": {}
    },
    "prevAutoResetPoints": null,
    "header": {
      "fields": {}
    },
    "parentInitiatedEventVersion": "0",
    "workflowId": "1ea52de8-f94e-437a-8026-67bc9525d3e4",
    "sourceVersionStamp": null
  }
}

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