From cbec48a6817fd25386d72807a301853866480858 Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Wed, 3 May 2023 12:00:07 -0400 Subject: [PATCH 1/8] add python tab to how-to Signed-off-by: Hannah Hunter --- .../workflow/howto-author-workflow.md | 81 ++++++++++++++++++- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md index b9f7d2607..543bb1c17 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md @@ -81,10 +81,12 @@ It also includes a `RunAsync` method that does the heavy lifting of the workflow Compose the workflow activities into a workflow. -{{< tabs ".NET" >}} +{{< tabs ".NET" Python >}} {{% codetab %}} + + [In the following example](https://github.com/dapr/dotnet-sdk/blob/master/examples/Workflow/WorkflowConsoleApp/Program.cs), for a basic ASP.NET order processing application using the .NET SDK, your project code would include: - A NuGet package called `Dapr.Workflow` to receive the .NET SDK capabilities @@ -152,8 +154,79 @@ app.Run(); {{% /codetab %}} -{{< /tabs >}} +{{% codetab %}} + + +[In the following example](todo), for a basic Python order processing application using the Python SDK, your project code would include: + +- A Python package called `DaprClient` to receive the Python SDK capabilities +- A builder with an extension method called `todo` + - This will allow you to register workflows and workflow activities (tasks that workflows can schedule) +- HTTP API calls + - **start_workflow**: Start an instance of a workflow + - **get_workflow**: Get information on a single workflow + - **terminate_workflow**: Terminate or stop a particular instance of a workflow + - **raise_event**: Raise an event on a workflow + - **pause_workflow**: Pauses or suspends a workflow instance that can later be resumed + - **resume_workflow**: Resumes a paused workflow instance + - **purge_workflow**: Removes all metadata related to a specific workflow instance + +```python +from dapr.clients import DaprClient + +from dapr.clients.grpc._helpers import to_bytes +# ... + +# Dapr Workflows are registered as part of the service configuration +with DaprClient() as d: + instanceId = "RRLINSTANCEID35" + workflowComponent = "dapr" + workflowName = "PlaceOrder" + workflowOptions = dict() + workflowOptions["task_queue"] = "testQueue" + inventoryItem = ("Computers", 5, 10) + item2 = "paperclips" + + encoded_data = b''.join(bytes(str(element), 'UTF-8') for element in item2) + encoded_data2 = json.dumps(item2).encode("UTF-8") + + # ... + + # Start the workflow + start_resp = d.start_workflow(instance_id=instanceId, workflow_component=workflowComponent, + workflow_name=workflowName, input=encoded_data2, workflow_options=workflowOptions) + print(f"Attempting to start {workflowName}") + print(f"start_resp {start_resp.instance_id}") + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after start call: {getResponse.runtime_status}") + + # Pause Test + d.pause_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after pause call: {getResponse.runtime_status}") + + # Resume Test + d.resume_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after resume call: {getResponse.runtime_status}") + + # Terminate Test + d.terminate_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after terminate call: {getResponse.runtime_status}") + + # Purge Test + d.purge_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after purge call: {getResponse}") +``` + + +{{% /codetab %}} + + +{{< /tabs >}} {{% alert title="Important" color="warning" %}} @@ -170,4 +243,6 @@ Now that you've authored a workflow, learn how to manage it. ## Related links - [Workflow overview]({{< ref workflow-overview.md >}}) - [Workflow API reference]({{< ref workflow_api.md >}}) -- [Try out the .NET example](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow) +- Try out the full SDK examples: + - [.NET example](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow) + - [Python example](todo) From 4f49c47111f0b33d71ea0c1d41df90229394d066 Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Wed, 3 May 2023 12:45:31 -0400 Subject: [PATCH 2/8] update other docs for python sdk Signed-off-by: Hannah Hunter --- .../workflow/howto-author-workflow.md | 32 +-------- .../workflow/howto-manage-workflow.md | 72 ++++++++++++++++++- .../workflow/workflow-overview.md | 8 ++- 3 files changed, 80 insertions(+), 32 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md index 543bb1c17..e30fec575 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md @@ -163,15 +163,8 @@ app.Run(); - A Python package called `DaprClient` to receive the Python SDK capabilities - A builder with an extension method called `todo` - This will allow you to register workflows and workflow activities (tasks that workflows can schedule) -- HTTP API calls - - **start_workflow**: Start an instance of a workflow - - **get_workflow**: Get information on a single workflow - - **terminate_workflow**: Terminate or stop a particular instance of a workflow - - **raise_event**: Raise an event on a workflow - - **pause_workflow**: Pauses or suspends a workflow instance that can later be resumed - - **resume_workflow**: Resumes a paused workflow instance - - **purge_workflow**: Removes all metadata related to a specific workflow instance - +- HTTP API calls to start, pause, resume, terminate, and purge the workflow. + ```python from dapr.clients import DaprClient @@ -198,28 +191,9 @@ with DaprClient() as d: workflow_name=workflowName, input=encoded_data2, workflow_options=workflowOptions) print(f"Attempting to start {workflowName}") print(f"start_resp {start_resp.instance_id}") + # Get workflow status getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) print(f"Get response from {workflowName} after start call: {getResponse.runtime_status}") - - # Pause Test - d.pause_workflow(instance_id=instanceId, workflow_component=workflowComponent) - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after pause call: {getResponse.runtime_status}") - - # Resume Test - d.resume_workflow(instance_id=instanceId, workflow_component=workflowComponent) - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after resume call: {getResponse.runtime_status}") - - # Terminate Test - d.terminate_workflow(instance_id=instanceId, workflow_component=workflowComponent) - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after terminate call: {getResponse.runtime_status}") - - # Purge Test - d.purge_workflow(instance_id=instanceId, workflow_component=workflowComponent) - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after purge call: {getResponse}") ``` diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md index b876c5d9f..5b5359277 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md @@ -8,7 +8,7 @@ description: Manage and run workflows Now that you've [authored the workflow and its activities in your application]({{< ref howto-author-workflow.md >}}), you can start, terminate, and get information about the workflow using HTTP API calls. For more information, read the [workflow API reference]({{< ref workflow_api.md >}}). -{{< tabs ".NET SDK" HTTP >}} +{{< tabs ".NET SDK" "Python SDK" HTTP >}} {{% codetab %}} @@ -35,6 +35,72 @@ await daprClient.TerminateWorkflowAsync(instanceId, workflowComponent); {{% /codetab %}} + +{{% codetab %}} + +Manage your workflow within your code. In the `OrderProcessingWorkflow` example from the [Author a workflow]({{< ref "howto-author-workflow.md#write-the-workflow" >}}) guide, the workflow is registered in the code using the following APIs: +- **start_workflow**: Start an instance of a workflow +- **get_workflow**: Get information on a single workflow +- **terminate_workflow**: Terminate or stop a particular instance of a workflow +- **raise_event**: Raise an event on a workflow +- **pause_workflow**: Pauses or suspends a workflow instance that can later be resumed +- **resume_workflow**: Resumes a paused workflow instance +- **purge_workflow**: Removes all metadata related to a specific workflow instance + +```python +from dapr.clients import DaprClient + +from dapr.clients.grpc._helpers import to_bytes +# ... + +# Dapr Workflows are registered as part of the service configuration +with DaprClient() as d: + instanceId = "RRLINSTANCEID35" + workflowComponent = "dapr" + workflowName = "PlaceOrder" + workflowOptions = dict() + workflowOptions["task_queue"] = "testQueue" + inventoryItem = ("Computers", 5, 10) + item2 = "paperclips" + + encoded_data = b''.join(bytes(str(element), 'UTF-8') for element in item2) + encoded_data2 = json.dumps(item2).encode("UTF-8") + + # ... + + # Start the workflow + start_resp = d.start_workflow(instance_id=instanceId, workflow_component=workflowComponent, + workflow_name=workflowName, input=encoded_data2, workflow_options=workflowOptions) + print(f"Attempting to start {workflowName}") + print(f"start_resp {start_resp.instance_id}") + # Get workflow status + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after start call: {getResponse.runtime_status}") + + # Pause Test + d.pause_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after pause call: {getResponse.runtime_status}") + + # Resume Test + d.resume_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after resume call: {getResponse.runtime_status}") + + # Terminate Test + d.terminate_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after terminate call: {getResponse.runtime_status}") + + # Purge Test + d.purge_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after purge call: {getResponse}") +``` + +{{% /codetab %}} + + {{% codetab %}} @@ -74,5 +140,7 @@ Learn more about these HTTP calls in the [workflow API reference guide]({{< ref ## Next steps - [Try out the Workflow quickstart]({{< ref workflow-quickstart.md >}}) -- [Try out the .NET example](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow) +- Try out the full SDK examples: + - [.NET example](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow) + - [Python example](todo) - [Workflow API reference]({{< ref workflow_api.md >}}) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md index 5afd25055..d2fe7664b 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md @@ -81,6 +81,8 @@ You can use the following SDKs to author a workflow. | Language stack | Package | | - | - | | .NET | [Dapr.Workflow](https://www.nuget.org/profiles/dapr.io) | +| Python | [StartWorkflowResponse](todo) | + ## Try out workflows @@ -92,6 +94,8 @@ Want to put workflows to the test? Walk through the following quickstart and tut | ------------------- | ----------- | | [Workflow quickstart]({{< ref workflow-quickstart.md >}}) | Run a .NET workflow application with four workflow activities to see Dapr Workflow in action | | [Workflow .NET SDK example](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow) | Learn how to create a Dapr Workflow and invoke it using ASP.NET Core web APIs. | +| [Workflow Python SDK example](todo) | Learn how to create a Dapr Workflow and invoke it using ASP.NET Core web APIs. | + ### Start using workflows directly in your app @@ -110,4 +114,6 @@ Watch [this video for an overview on Dapr Workflow](https://youtu.be/s1p9MNl4VGo ## Related links - [Workflow API reference]({{< ref workflow_api.md >}}) -- [Try out the .NET example](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow) +- Try out the full SDK examples: + - [.NET example](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow) + - [Python example](todo) From 29ce06fc1d57c6c1a507857feec491b4cb50b07e Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Mon, 8 May 2023 15:20:06 -0400 Subject: [PATCH 3/8] add python tab Signed-off-by: Hannah Hunter --- .../workflow/howto-author-workflow.md | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md index e30fec575..d9bbb6769 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md @@ -30,7 +30,7 @@ The Dapr sidecar doesn’t load any workflow definitions. Rather, the sidecar si Define the workflow activities you'd like your workflow to perform. Activities are a class definition and can take inputs and outputs. Activities also participate in dependency injection, like binding to a Dapr client. -{{< tabs ".NET" >}} +{{< tabs ".NET" Python >}} {{% codetab %}} @@ -73,6 +73,24 @@ It also includes a `RunAsync` method that does the heavy lifting of the workflow } ``` +{{% /codetab %}} + +{{% codetab %}} + + + +[In the following example](todo), for a basic Python order processing application using the Python SDK, your project code would include: + +- A Python package called `DaprClient` to receive the Python SDK capabilities +- A builder with an extension method called `todo` + - This will allow you to register workflows and workflow activities (tasks that workflows can schedule) +- HTTP API calls to start, pause, resume, terminate, and purge the workflow. + +```python +todo +``` + + {{% /codetab %}} {{< /tabs >}} From 7b1d40641a8374eed4e3fec831d5ef7f5177bd78 Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Mon, 8 May 2023 15:54:36 -0400 Subject: [PATCH 4/8] update python tabs, remove sdk from tabs Signed-off-by: Hannah Hunter --- .../workflow/howto-author-workflow.md | 50 +++++++++++- .../workflow/howto-manage-workflow.md | 80 +++++++++---------- 2 files changed, 89 insertions(+), 41 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md index d9bbb6769..bc326c429 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md @@ -87,7 +87,55 @@ It also includes a `RunAsync` method that does the heavy lifting of the workflow - HTTP API calls to start, pause, resume, terminate, and purge the workflow. ```python -todo +from dapr.clients import DaprClient + +from dapr.clients.grpc._helpers import to_bytes +# ... + +# Dapr Workflows are registered as part of the service configuration +with DaprClient() as d: + instanceId = "RRLINSTANCEID35" + workflowComponent = "dapr" + workflowName = "PlaceOrder" + workflowOptions = dict() + workflowOptions["task_queue"] = "testQueue" + inventoryItem = ("Computers", 5, 10) + item2 = "paperclips" + + encoded_data = b''.join(bytes(str(element), 'UTF-8') for element in item2) + encoded_data2 = json.dumps(item2).encode("UTF-8") + + # ... + + # Start the workflow + start_resp = d.start_workflow(instance_id=instanceId, workflow_component=workflowComponent, + workflow_name=workflowName, input=encoded_data2, workflow_options=workflowOptions) + print(f"Attempting to start {workflowName}") + print(f"start_resp {start_resp.instance_id}") + # Get workflow status + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after start call: {getResponse.runtime_status}") + + # Pause Test + d.pause_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after pause call: {getResponse.runtime_status}") + + # Resume Test + d.resume_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after resume call: {getResponse.runtime_status}") + + # Terminate Test + d.terminate_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after terminate call: {getResponse.runtime_status}") + + # Purge Test + d.purge_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after purge call: {getResponse}") + ``` diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md index 35f4f2fa1..09b616c34 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md @@ -8,7 +8,7 @@ description: Manage and run workflows Now that you've [authored the workflow and its activities in your application]({{< ref howto-author-workflow.md >}}), you can start, terminate, and get information about the workflow using HTTP API calls. For more information, read the [workflow API reference]({{< ref workflow_api.md >}}). -{{< tabs ".NET SDK" "Python SDK" HTTP >}} +{{< tabs ".NET" Python HTTP >}} {{% codetab %}} @@ -48,54 +48,54 @@ Manage your workflow within your code. In the `OrderProcessingWorkflow` example - **purge_workflow**: Removes all metadata related to a specific workflow instance ```python -from dapr.clients import DaprClient +dapr = DaprGrpcClient(f'localhost:{self.server_port}') -from dapr.clients.grpc._helpers import to_bytes -# ... +# Sane parameters +workflow_name = 'testWorkflow' +instance_id = str(uuid.uuid4()) +workflow_component = "dapr" +input = "paperclips" -# Dapr Workflows are registered as part of the service configuration -with DaprClient() as d: - instanceId = "RRLINSTANCEID35" - workflowComponent = "dapr" - workflowName = "PlaceOrder" - workflowOptions = dict() - workflowOptions["task_queue"] = "testQueue" - inventoryItem = ("Computers", 5, 10) - item2 = "paperclips" +# Start the workflow +start_response = dapr.start_workflow(instance_id, workflow_name, workflow_component, + input.encode('utf-8'), None) +self.assertEqual(instance_id, start_response.instance_id) - encoded_data = b''.join(bytes(str(element), 'UTF-8') for element in item2) - encoded_data2 = json.dumps(item2).encode("UTF-8") - # ... - # Start the workflow - start_resp = d.start_workflow(instance_id=instanceId, workflow_component=workflowComponent, - workflow_name=workflowName, input=encoded_data2, workflow_options=workflowOptions) - print(f"Attempting to start {workflowName}") - print(f"start_resp {start_resp.instance_id}") - # Get workflow status - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after start call: {getResponse.runtime_status}") +# Get info on the workflow to check that it is running +get_response = dapr.get_workflow(instance_id, workflow_component) +self.assertEqual("RUNNING", get_response.runtime_status) - # Pause Test - d.pause_workflow(instance_id=instanceId, workflow_component=workflowComponent) - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after pause call: {getResponse.runtime_status}") +# Pause the workflow +dapr.pause_workflow(instance_id, workflow_component) - # Resume Test - d.resume_workflow(instance_id=instanceId, workflow_component=workflowComponent) - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after resume call: {getResponse.runtime_status}") +# Get info on the workflow to check that it is paused +get_response = dapr.get_workflow(instance_id, workflow_component) +self.assertEqual("SUSPENDED", get_response.runtime_status) - # Terminate Test - d.terminate_workflow(instance_id=instanceId, workflow_component=workflowComponent) - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after terminate call: {getResponse.runtime_status}") +# Resume the workflow +dapr.resume_workflow(instance_id, workflow_component) - # Purge Test - d.purge_workflow(instance_id=instanceId, workflow_component=workflowComponent) - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after purge call: {getResponse}") +# Get info on the workflow to check that it is resumed +get_response = dapr.get_workflow(instance_id, workflow_component) +self.assertEqual("RUNNING", get_response.runtime_status) + +# Raise an event on the workflow. +TODO: Figure out how to check/verify this + +# Terminate the workflow +dapr.terminate_workflow(instance_id, workflow_component) + +# Get info on the workflow to check that it is terminated +get_response = dapr.get_workflow(instance_id, workflow_component) +self.assertEqual("TERMINATED", get_response.runtime_status) + +# Purge the workflow +dapr.purge_workflow(instance_id, workflow_component) + +# Get information on the workflow to ensure that it has been purged +TODO ``` {{% /codetab %}} From d85b49abb7473cd4c1b8cb4bc45a7afaa0359ed7 Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Tue, 9 May 2023 10:05:04 -0400 Subject: [PATCH 5/8] remove python examples until ready Signed-off-by: Hannah Hunter --- .../workflow/howto-author-workflow.md | 81 +------------------ 1 file changed, 3 insertions(+), 78 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md index bc326c429..f275c5ddd 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md @@ -28,7 +28,7 @@ The Dapr sidecar doesn’t load any workflow definitions. Rather, the sidecar si ## Write the workflow activities -Define the workflow activities you'd like your workflow to perform. Activities are a class definition and can take inputs and outputs. Activities also participate in dependency injection, like binding to a Dapr client. +Define the workflow activities you’d like your workflow to perform. Activities are a class definition and can take inputs and outputs. Activities also participate in dependency injection, like binding to a Dapr client. {{< tabs ".NET" Python >}} @@ -87,55 +87,7 @@ It also includes a `RunAsync` method that does the heavy lifting of the workflow - HTTP API calls to start, pause, resume, terminate, and purge the workflow. ```python -from dapr.clients import DaprClient - -from dapr.clients.grpc._helpers import to_bytes -# ... - -# Dapr Workflows are registered as part of the service configuration -with DaprClient() as d: - instanceId = "RRLINSTANCEID35" - workflowComponent = "dapr" - workflowName = "PlaceOrder" - workflowOptions = dict() - workflowOptions["task_queue"] = "testQueue" - inventoryItem = ("Computers", 5, 10) - item2 = "paperclips" - - encoded_data = b''.join(bytes(str(element), 'UTF-8') for element in item2) - encoded_data2 = json.dumps(item2).encode("UTF-8") - - # ... - - # Start the workflow - start_resp = d.start_workflow(instance_id=instanceId, workflow_component=workflowComponent, - workflow_name=workflowName, input=encoded_data2, workflow_options=workflowOptions) - print(f"Attempting to start {workflowName}") - print(f"start_resp {start_resp.instance_id}") - # Get workflow status - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after start call: {getResponse.runtime_status}") - - # Pause Test - d.pause_workflow(instance_id=instanceId, workflow_component=workflowComponent) - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after pause call: {getResponse.runtime_status}") - - # Resume Test - d.resume_workflow(instance_id=instanceId, workflow_component=workflowComponent) - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after resume call: {getResponse.runtime_status}") - - # Terminate Test - d.terminate_workflow(instance_id=instanceId, workflow_component=workflowComponent) - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after terminate call: {getResponse.runtime_status}") - - # Purge Test - d.purge_workflow(instance_id=instanceId, workflow_component=workflowComponent) - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after purge call: {getResponse}") - +todo ``` @@ -232,34 +184,7 @@ app.Run(); - HTTP API calls to start, pause, resume, terminate, and purge the workflow. ```python -from dapr.clients import DaprClient - -from dapr.clients.grpc._helpers import to_bytes -# ... - -# Dapr Workflows are registered as part of the service configuration -with DaprClient() as d: - instanceId = "RRLINSTANCEID35" - workflowComponent = "dapr" - workflowName = "PlaceOrder" - workflowOptions = dict() - workflowOptions["task_queue"] = "testQueue" - inventoryItem = ("Computers", 5, 10) - item2 = "paperclips" - - encoded_data = b''.join(bytes(str(element), 'UTF-8') for element in item2) - encoded_data2 = json.dumps(item2).encode("UTF-8") - - # ... - - # Start the workflow - start_resp = d.start_workflow(instance_id=instanceId, workflow_component=workflowComponent, - workflow_name=workflowName, input=encoded_data2, workflow_options=workflowOptions) - print(f"Attempting to start {workflowName}") - print(f"start_resp {start_resp.instance_id}") - # Get workflow status - getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) - print(f"Get response from {workflowName} after start call: {getResponse.runtime_status}") +todo ``` From ca68c40b1e3ec182551ce2b8858e6a2ed0a025be Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Tue, 6 Jun 2023 10:46:34 -0400 Subject: [PATCH 6/8] add python Signed-off-by: Hannah Hunter --- .../workflow/howto-author-workflow.md | 128 +++++++++++++++--- .../workflow/howto-manage-workflow.md | 64 ++++----- .../workflow/workflow-overview.md | 4 +- 3 files changed, 138 insertions(+), 58 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md index fbb038ec7..741b45b7d 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md @@ -34,6 +34,8 @@ The Dapr sidecar doesn’t load any workflow definitions. Rather, the sidecar si {{% codetab %}} + + Define the workflow activities you'd like your workflow to perform. Activities are a class definition and can take inputs and outputs. Activities also participate in dependency injection, like binding to a Dapr client. The activities called in the example below are: @@ -96,6 +98,24 @@ public class ProcessPaymentActivity : WorkflowActivity [See the full `ProcessPaymentActivity.cs` workflow activity example.](https://github.com/dapr/dotnet-sdk/blob/master/examples/Workflow/WorkflowConsoleApp/Activities/ProcessPaymentActivity.cs) +{{% /codetab %}} + +{{% codetab %}} + + + +Define the workflow activities you'd like your workflow to perform. Activities are a function definition and can take inputs and outputs. The following example creates a counter (activity) called `hello_act` that notifies users of the current counter value. `hello_act` is a function derived from a class called `WorkflowActivityContext`. + +```python +def hello_act(ctx: WorkflowActivityContext, input): + global counter + counter += input + print(f'New counter value is: {counter}!', flush=True) +``` + +[See the `hello_act` workflow activity in context.](https://github.com/dapr/python-sdk/blob/master/examples/demo_workflow/app.py#LL40C1-L43C59) + + {{% /codetab %}} {{< /tabs >}} @@ -104,10 +124,12 @@ public class ProcessPaymentActivity : WorkflowActivity Next, register and call the activites in a workflow. -{{< tabs ".NET" >}} +{{< tabs ".NET" Python >}} {{% codetab %}} + + The `OrderProcessingWorkflow` class is derived from a base class called `Workflow` with input and output parameter types. It also includes a `RunAsync` method that does the heavy lifting of the workflow and calls the workflow activities. ```csharp @@ -142,25 +164,29 @@ The `OrderProcessingWorkflow` class is derived from a base class called `Workflo } ``` +[See the full workflow example in `OrderProcessingWorkflow.cs`.](https://github.com/dapr/dotnet-sdk/blob/master/examples/Workflow/WorkflowConsoleApp/Workflows/OrderProcessingWorkflow.cs) + + {{% /codetab %}} {{% codetab %}} -[In the following example](todo), for a basic Python order processing application using the Python SDK, your project code would include: - -- A Python package called `DaprClient` to receive the Python SDK capabilities -- A builder with an extension method called `todo` - - This will allow you to register workflows and workflow activities (tasks that workflows can schedule) -- HTTP API calls to start, pause, resume, terminate, and purge the workflow. +The `hello_world_wf` function is derived from a class called `DaprWorkflowContext` with input and output parameter types. It also includes a `yield` statement that does the heavy lifting of the workflow and calls the workflow activities. ```python -todo +def hello_world_wf(ctx: DaprWorkflowContext, input): + print(f'{input}') + yield ctx.call_activity(hello_act, input=1) + yield ctx.call_activity(hello_act, input=10) + yield ctx.wait_for_external_event("event1") + yield ctx.call_activity(hello_act, input=100) + yield ctx.call_activity(hello_act, input=1000) ``` +[See the `hello_world_wf` workflow in context.](https://github.com/dapr/python-sdk/blob/master/examples/demo_workflow/app.py#LL32C1-L38C51) -[See the full workflow example in `OrderProcessingWorkflow.cs`.](https://github.com/dapr/dotnet-sdk/blob/master/examples/Workflow/WorkflowConsoleApp/Workflows/OrderProcessingWorkflow.cs) {{% /codetab %}} @@ -176,7 +202,6 @@ Finally, compose the application using the workflow. -[In the following example](https://github.com/dapr/dotnet-sdk/blob/master/examples/Workflow/WorkflowConsoleApp/Program.cs), for a basic ASP.NET order processing application using the .NET SDK, your project code would include: [In the following `Program.cs` example](https://github.com/dapr/dotnet-sdk/blob/master/examples/Workflow/WorkflowConsoleApp/Program.cs), for a basic ASP.NET order processing application using the .NET SDK, your project code would include: - A NuGet package called `Dapr.Workflow` to receive the .NET SDK capabilities @@ -248,15 +273,86 @@ app.Run(); -[In the following example](todo), for a basic Python order processing application using the Python SDK, your project code would include: +[In the following example](https://github.com/dapr/python-sdk/blob/master/examples/demo_workflow/app.py), for a basic Python order processing application using the Python SDK, your project code would include: -- A Python package called `DaprClient` to receive the Python SDK capabilities -- A builder with an extension method called `todo` - - This will allow you to register workflows and workflow activities (tasks that workflows can schedule) -- HTTP API calls to start, pause, resume, terminate, and purge the workflow. +- A Python package called `DaprClient` to receive the Python SDK capabilities. +- A builder with extensions called: + - `WorkflowRuntime`: Allows you to register workflows and workflow activities + - `DaprWorkflowContext`: Allows you to [create workflows]({{< ref "#write-the-workflow" >}}) + - `WorkflowActivityContext`: Allows you to [create workflow activities]({{< ref "#write-the-workflow-activities" >}}) +- HTTP API calls. In the example below, these calls start, pause, resume, purge, and terminate the workflow. ```python -todo +from dapr.ext.workflow import WorkflowRuntime, DaprWorkflowContext, WorkflowActivityContext +from dapr.clients import DaprClient + +# ... + +def main(): + with DaprClient() as d: + host = settings.DAPR_RUNTIME_HOST + port = settings.DAPR_GRPC_PORT + workflowRuntime = WorkflowRuntime(host, port) + workflowRuntime = WorkflowRuntime() + workflowRuntime.register_workflow(hello_world_wf) + workflowRuntime.register_activity(hello_act) + workflowRuntime.start() + + # Start workflow + print("==========Start Counter Increase as per Input:==========") + start_resp = d.start_workflow(instance_id=instanceId, workflow_component=workflowComponent, + workflow_name=workflowName, input=inputData, workflow_options=workflowOptions) + print(f"start_resp {start_resp.instance_id}") + + # ... + + # Pause Test + d.pause_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after pause call: {getResponse.runtime_status}") + + # Resume Test + d.resume_workflow(instance_id=instanceId, workflow_component=workflowComponent) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after resume call: {getResponse.runtime_status}") + + sleep(1) + # Raise event + d.raise_workflow_event(instance_id=instanceId, workflow_component=workflowComponent, + event_name=eventName, event_data=eventData) + + sleep(5) + # Purge Test + d.purge_workflow(instance_id=instanceId, workflow_component=workflowComponent) + try: + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + except DaprInternalError as err: + if nonExistentIDError in err._message: + print("Instance Successfully Purged") + + # Kick off another workflow for termination purposes + start_resp = d.start_workflow(instance_id=instanceId, workflow_component=workflowComponent, + workflow_name=workflowName, input=inputData, workflow_options=workflowOptions) + print(f"start_resp {start_resp.instance_id}") + + # Terminate Test + d.terminate_workflow(instance_id=instanceId, workflow_component=workflowComponent) + sleep(1) + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + print(f"Get response from {workflowName} after terminate call: {getResponse.runtime_status}") + + # Purge Test + d.purge_workflow(instance_id=instanceId, workflow_component=workflowComponent) + try: + getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) + except DaprInternalError as err: + if nonExistentIDError in err._message: + print("Instance Successfully Purged") + + workflowRuntime.shutdown() + +if __name__ == '__main__': + main() ``` diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md index 4fa92ab5b..99cb87c9b 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md @@ -13,7 +13,7 @@ Now that you've [authored the workflow and its activities in your application]({ {{% codetab %}} -Manage your workflow within your code. In the `OrderProcessingWorkflow` example from the [Author a workflow]({{< ref "howto-author-workflow.md#write-the-workflow" >}}) guide, the workflow is registered in the code. You can now start, terminate, and get information about a running workflow: +Manage your workflow within your code. In the `OrderProcessingWorkflow` example from the [Author a workflow]({{< ref "howto-author-workflow.md#write-the-application" >}}) guide, the workflow is registered in the code. You can now start, terminate, and get information about a running workflow: ```csharp string orderId = "exampleOrderId"; @@ -49,64 +49,48 @@ await daprClient.PurgeWorkflowAsync(orderId, workflowComponent); {{% codetab %}} -Manage your workflow within your code. In the `OrderProcessingWorkflow` example from the [Author a workflow]({{< ref "howto-author-workflow.md#write-the-workflow" >}}) guide, the workflow is registered in the code using the following APIs: +Manage your workflow within your code. In the workflow example from the [Author a workflow]({{< ref "howto-author-workflow.md#write-the-application" >}}) guide, the workflow is registered in the code using the following APIs: - **start_workflow**: Start an instance of a workflow -- **get_workflow**: Get information on a single workflow -- **terminate_workflow**: Terminate or stop a particular instance of a workflow -- **raise_event**: Raise an event on a workflow +- **get_workflow**: Get information on the status of the workflow - **pause_workflow**: Pauses or suspends a workflow instance that can later be resumed - **resume_workflow**: Resumes a paused workflow instance +- **raise_workflow_event**: Raise an event on a workflow - **purge_workflow**: Removes all metadata related to a specific workflow instance +- **terminate_workflow**: Terminate or stop a particular instance of a workflow ```python -dapr = DaprGrpcClient(f'localhost:{self.server_port}') +from dapr.ext.workflow import WorkflowRuntime, DaprWorkflowContext, WorkflowActivityContext +from dapr.clients import DaprClient # Sane parameters -workflow_name = 'testWorkflow' -instance_id = str(uuid.uuid4()) -workflow_component = "dapr" -input = "paperclips" +instanceId = "exampleInstanceID" +workflowComponent = "dapr" +workflowName = "hello_world_wf" +eventName = "event1" +eventData = "eventData" # Start the workflow -start_response = dapr.start_workflow(instance_id, workflow_name, workflow_component, - input.encode('utf-8'), None) -self.assertEqual(instance_id, start_response.instance_id) +start_resp = d.start_workflow(instance_id=instanceId, workflow_component=workflowComponent, + workflow_name=workflowName, input=inputData, workflow_options=workflowOptions) - - -# Get info on the workflow to check that it is running -get_response = dapr.get_workflow(instance_id, workflow_component) -self.assertEqual("RUNNING", get_response.runtime_status) +# Get info on the workflow +getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) # Pause the workflow -dapr.pause_workflow(instance_id, workflow_component) - -# Get info on the workflow to check that it is paused -get_response = dapr.get_workflow(instance_id, workflow_component) -self.assertEqual("SUSPENDED", get_response.runtime_status) +d.pause_workflow(instance_id=instanceId, workflow_component=workflowComponent) # Resume the workflow -dapr.resume_workflow(instance_id, workflow_component) - -# Get info on the workflow to check that it is resumed -get_response = dapr.get_workflow(instance_id, workflow_component) -self.assertEqual("RUNNING", get_response.runtime_status) +d.resume_workflow(instance_id=instanceId, workflow_component=workflowComponent) # Raise an event on the workflow. -TODO: Figure out how to check/verify this - -# Terminate the workflow -dapr.terminate_workflow(instance_id, workflow_component) - -# Get info on the workflow to check that it is terminated -get_response = dapr.get_workflow(instance_id, workflow_component) -self.assertEqual("TERMINATED", get_response.runtime_status) + d.raise_workflow_event(instance_id=instanceId, workflow_component=workflowComponent, + event_name=eventName, event_data=eventData) # Purge the workflow -dapr.purge_workflow(instance_id, workflow_component) +d.purge_workflow(instance_id=instanceId, workflow_component=workflowComponent) -# Get information on the workflow to ensure that it has been purged -TODO +# Terminate the workflow +d.terminate_workflow(instance_id=instanceId, workflow_component=workflowComponent) ``` {{% /codetab %}} @@ -189,5 +173,5 @@ Learn more about these HTTP calls in the [workflow API reference guide]({{< ref - [Try out the Workflow quickstart]({{< ref workflow-quickstart.md >}}) - Try out the full SDK examples: - [.NET example](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow) - - [Python example](todo) + - [Python example](https://github.com/dapr/python-sdk/blob/master/examples/demo_workflow/app.py) - [Workflow API reference]({{< ref workflow_api.md >}}) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md index d2fe7664b..748e5e96c 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md @@ -81,7 +81,7 @@ You can use the following SDKs to author a workflow. | Language stack | Package | | - | - | | .NET | [Dapr.Workflow](https://www.nuget.org/profiles/dapr.io) | -| Python | [StartWorkflowResponse](todo) | +| Python | [dapr-ext-workflow](https://github.com/dapr/python-sdk/tree/master/ext/dapr-ext-workflow) | ## Try out workflows @@ -94,7 +94,7 @@ Want to put workflows to the test? Walk through the following quickstart and tut | ------------------- | ----------- | | [Workflow quickstart]({{< ref workflow-quickstart.md >}}) | Run a .NET workflow application with four workflow activities to see Dapr Workflow in action | | [Workflow .NET SDK example](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow) | Learn how to create a Dapr Workflow and invoke it using ASP.NET Core web APIs. | -| [Workflow Python SDK example](todo) | Learn how to create a Dapr Workflow and invoke it using ASP.NET Core web APIs. | +| [Workflow Python SDK example](https://github.com/dapr/python-sdk/tree/master/examples/demo_workflow) | Learn how to create a Dapr Workflow and invoke it using the Python `DaprClient` package. | ### Start using workflows directly in your app From baa3c57066436bdbbc9828232097752b422179e5 Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Tue, 6 Jun 2023 18:21:03 -0400 Subject: [PATCH 7/8] 'ryan-review' Signed-off-by: Hannah Hunter --- .../building-blocks/workflow/howto-author-workflow.md | 4 ++-- .../building-blocks/workflow/workflow-overview.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md index 741b45b7d..0e1ac145a 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md @@ -280,7 +280,7 @@ app.Run(); - `WorkflowRuntime`: Allows you to register workflows and workflow activities - `DaprWorkflowContext`: Allows you to [create workflows]({{< ref "#write-the-workflow" >}}) - `WorkflowActivityContext`: Allows you to [create workflow activities]({{< ref "#write-the-workflow-activities" >}}) -- HTTP API calls. In the example below, these calls start, pause, resume, purge, and terminate the workflow. +- API calls. In the example below, these calls start, pause, resume, purge, and terminate the workflow. ```python from dapr.ext.workflow import WorkflowRuntime, DaprWorkflowContext, WorkflowActivityContext @@ -378,4 +378,4 @@ Now that you've authored a workflow, learn how to manage it. - [Workflow API reference]({{< ref workflow_api.md >}}) - Try out the full SDK examples: - [.NET example](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow) - - [Python example](todo) + - [Python example](https://github.com/dapr/python-sdk/tree/master/examples/demo_workflow) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md index 748e5e96c..20418d9c7 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md @@ -116,4 +116,4 @@ Watch [this video for an overview on Dapr Workflow](https://youtu.be/s1p9MNl4VGo - [Workflow API reference]({{< ref workflow_api.md >}}) - Try out the full SDK examples: - [.NET example](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow) - - [Python example](todo) + - [Python example](https://github.com/dapr/python-sdk/tree/master/examples/demo_workflow) From 02de603e4531f4ad03a11667d97c20b50a0f6bb4 Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Tue, 6 Jun 2023 20:18:08 -0400 Subject: [PATCH 8/8] 'mark-review' Signed-off-by: Hannah Hunter --- .../workflow/howto-author-workflow.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md index 0e1ac145a..6caa7f3ff 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md @@ -273,7 +273,7 @@ app.Run(); -[In the following example](https://github.com/dapr/python-sdk/blob/master/examples/demo_workflow/app.py), for a basic Python order processing application using the Python SDK, your project code would include: +[In the following example](https://github.com/dapr/python-sdk/blob/master/examples/demo_workflow/app.py), for a basic Python hello world application using the Python SDK, your project code would include: - A Python package called `DaprClient` to receive the Python SDK capabilities. - A builder with extensions called: @@ -306,23 +306,23 @@ def main(): # ... - # Pause Test + # Pause workflow d.pause_workflow(instance_id=instanceId, workflow_component=workflowComponent) getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) print(f"Get response from {workflowName} after pause call: {getResponse.runtime_status}") - # Resume Test + # Resume workflow d.resume_workflow(instance_id=instanceId, workflow_component=workflowComponent) getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) print(f"Get response from {workflowName} after resume call: {getResponse.runtime_status}") sleep(1) - # Raise event + # Raise workflow d.raise_workflow_event(instance_id=instanceId, workflow_component=workflowComponent, event_name=eventName, event_data=eventData) sleep(5) - # Purge Test + # Purge workflow d.purge_workflow(instance_id=instanceId, workflow_component=workflowComponent) try: getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) @@ -335,13 +335,13 @@ def main(): workflow_name=workflowName, input=inputData, workflow_options=workflowOptions) print(f"start_resp {start_resp.instance_id}") - # Terminate Test + # Terminate workflow d.terminate_workflow(instance_id=instanceId, workflow_component=workflowComponent) sleep(1) getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent) print(f"Get response from {workflowName} after terminate call: {getResponse.runtime_status}") - # Purge Test + # Purge workflow d.purge_workflow(instance_id=instanceId, workflow_component=workflowComponent) try: getResponse = d.get_workflow(instance_id=instanceId, workflow_component=workflowComponent)