quickstarts/tutorials/workflow/python/fundamentals
Marc Duiker e16a4ca57c
Update tutorials/workflow/python/fundamentals/basic/basic_workflow.py
Co-authored-by: Alice Gibbons <alicejgibbons@gmail.com>
Signed-off-by: Marc Duiker <marcduiker@users.noreply.github.com>
2025-05-20 07:49:23 +02:00
..
basic Update tutorials/workflow/python/fundamentals/basic/basic_workflow.py 2025-05-20 07:49:23 +02:00
README.md Change import, add task chaining and fan-in fan-out 2025-05-07 14:13:51 +02:00
dapr.yaml Add fundamentals example for Python 2025-05-06 15:42:26 +02:00
fundamentals.http Add fundamentals example for Python 2025-05-06 15:42:26 +02:00
makefile Add fundamentals example for Python 2025-05-06 15:42:26 +02:00

README.md

Workflow Basics

This tutorial covers the fundamentals of authoring Dapr Workflows. For more information about the fundamentals of Dapr Workflows, see the Dapr docs.

Inspect the code

Open the basic_workflow.py file in the tutorials/workflow/python/fundamentals/basic folder. This file contains the definition for the workflow.

The workflow consists of two activities: activity1 and activity2, which are called in sequence, where the result of activity1 is used as an input for activity2. You can find the activity definitions below the workflow definition.

graph LR
   SW((Start
   Workflow))
   A1[activity1]
   A2[activity2]
   EW((End
   Workflow))
   SW --> A1
   A1 --> A2
   A2 --> EW

Run the tutorial

  1. Use a terminal to navigate to the tutorials/workflow/python/fundamentals/basics folder.

  2. Install the dependencies using pip:

    pip3 install -r requirements.txt
    
  3. Navigate one level back to the fundamentals folder and use the Dapr CLI to run the Dapr Multi-App run file

    ```bash
    

    dapr run -f .

    <!-- END_STEP -->
    
    
  4. Use the POST request in the fundamentals.http file to start the workflow, or use this cURL command:

    curl -i --request POST http://localhost:5254/start/One
    

    Note the instance_id property in the response. This property contains the workflow instance ID. You can use this ID to get the status of the workflow instance you just started.

    The input for the workflow is a string with the value One. The expected app logs are as follows:

    == APP - basic == activity1: Received input: One.
    == APP - basic == activity2: Received input: One Two.
    
  5. Use the GET request in the fundamentals.http file to get the status of the workflow, or use this cURL command:

    curl --request GET --url http://localhost:3554/v1.0/workflows/dapr/<INSTANCEID>
    

    Where <INSTANCEID> is the workflow instance ID you received in the instance_id property in the previous step.

    The expected serialized output of the workflow is:

    "\"One Two Three\""
    
  6. Stop the Dapr Multi-App run process by pressing Ctrl+C.