Skip to content

python tutorial for workflow versioning#1277

Merged
alicejgibbons merged 9 commits intodapr:release-1.17from
acroca:workflow-versioning
Feb 13, 2026
Merged

python tutorial for workflow versioning#1277
alicejgibbons merged 9 commits intodapr:release-1.17from
acroca:workflow-versioning

Conversation

@acroca
Copy link
Member

@acroca acroca commented Jan 27, 2026

Ref: #1274
Close: #1281

Adds a tutorial demonstrating how to use the two workflow versioning mechanisms.

acroca and others added 3 commits January 27, 2026 15:32
Signed-off-by: Albert Callarisa <albert@diagrid.io>
Signed-off-by: Albert Callarisa <albert@diagrid.io>
@acroca acroca marked this pull request as ready for review January 28, 2026 06:24
@acroca acroca requested review from a team as code owners January 28, 2026 06:24
@alicejgibbons
Copy link
Contributor

alicejgibbons commented Feb 4, 2026

@acroca I updated the branch to 1.17 to get the tests to pass.

@alicejgibbons alicejgibbons changed the base branch from master to release-1.17 February 4, 2026 12:10
Copy link
Contributor

@alicejgibbons alicejgibbons left a comment

Choose a reason for hiding this comment

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

Am going to let @marcduiker review this one since it will be used for DaprU and will be the basis for the other tutorials

A2 --> EW
```

The workflow starts by evaluating whether the `patch1` patch is patched. If it is, the workflow will continue to the `activity1` activity. If it is not, the workflow will continue to the `activity2` activity.
Copy link
Contributor

Choose a reason for hiding this comment

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

Im a bit confused by this example still. For instance, here, can we add what workflows_instances means in this context?

Like so is_patched is part of the workflow context and is set where? Is this an input param? https://github.com/dapr/quickstarts/pull/1277/changes#diff-3a044745ae283d6ad936247cd9f6a8d406edf23815b1bbc4f26085e2ef3b8bc4R5

Also can we give a bit more details in terms of the if the workflow name has any significance.

Copy link
Member Author

Choose a reason for hiding this comment

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

The workflow_instances in the app.py is just the response from the API call to the example app that returns the workflow IDs that it created. Kind of the same as the workflow-manament example, but returning two workflow instances instead of only one, because we use two workflows.

The is_patched is not set anywhere, is the function we expose in the workflow context to do patch-style versioning. Patching is described in the docs (PR).

The workflow name doesn't mean anything, users can use any name workflows any way they want. I don't know if that's worth mentioning, we can't add a note for every concept that is not related to versioning, it might confuse people more than help. If they want more information on the specifics they can always visit the docs

Signed-off-by: Albert Callarisa <albert@diagrid.io>
Signed-off-by: Albert Callarisa <albert@diagrid.io>
Signed-off-by: Albert Callarisa <albert@diagrid.io>

## Inspect the named versioned workflow

Open the `after_named_version.py` file. This file shows how to migrate the workflow using named versions. A new version of the workflow (`notify_user`) is created that calls `send_sms`, while the original version is kept as `notify_user_v1` for any in-flight workflow instances.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Open the `after_named_version.py` file. This file shows how to migrate the workflow using named versions. A new version of the workflow (`notify_user`) is created that calls `send_sms`, while the original version is kept as `notify_user_v1` for any in-flight workflow instances.
Review the `after_named_version.py` file. This file shows how to create a new workflow version using named versions. A new version of the workflow (`notify_user`) is created that calls the `send_sms` activity, while the original version is kept as `notify_user_v1` for any workflow instances that might already be running.

SW2 --> SS --> EW2
```

The workflow engine will always execute the latest version of the workflow for new instances. Older versions will only be executed for workflows that were already in-flight when the update was deployed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The workflow engine will always execute the latest version of the workflow for new instances. Older versions will only be executed for workflows that were already in-flight when the update was deployed.
The workflow engine will always execute the latest version of the workflow when new instances are started. Older versions will only be executed for workflows that were already in-flight when the update was deployed.


## Inspect the patching workflow

Open the `after_patching.py` file. This file shows how to migrate the workflow using patching. The `ctx.is_patched("send_sms")` check determines whether the workflow should execute the new `send_sms` activity or the original `send_email` activity.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Open the `after_patching.py` file. This file shows how to migrate the workflow using patching. The `ctx.is_patched("send_sms")` check determines whether the workflow should execute the new `send_sms` activity or the original `send_email` activity.
Review the `after_patching.py` file. This file shows how to create a new workflow version using patching. The `ctx.is_patched("send_sms")` check determines whether the workflow should execute the new `send_sms` activity or the original `send_email` activity based on if the patch `send_sms` is applied.

Copy link
Contributor

Choose a reason for hiding this comment

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

@acroca does this make sense?

P -- No --> SE --> EW
```

New workflow instances will execute the patched code path (`send_sms`), while in-flight workflows will continue using the original code path (`send_email`).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
New workflow instances will execute the patched code path (`send_sms`), while in-flight workflows will continue using the original code path (`send_email`).
New workflow instances will execute the patched code path (`send_sms`) since the workflow has already had a patch applied, while already started, in-flight workflows will continue using the original code path (`send_email`).

pip3 install -r requirements.txt
```

3. Navigate back one level to the `versioning` folder. The `dapr.yaml` file is configured to run `before.py` by default. To try a versioned workflow, update the `command` field in `dapr.yaml` to run `after_named_version.py` or `after_patching.py` instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

Add example here on how to change it

== APP - versioning == send_email: Received input: user_id.
```

When running `after_named_version.py` or `after_patching.py`, the expected app logs are:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
When running `after_named_version.py` or `after_patching.py`, the expected app logs are:
When running `after_named_version.py` or `after_patching.py`, the expected app logs change from `send_email` to `send_sms` and are:

Signed-off-by: Albert Callarisa <albert@diagrid.io>
Copy link
Contributor

@marcduiker marcduiker left a comment

Choose a reason for hiding this comment

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

One old wf name needs to be updated, rest looks good 👍

Signed-off-by: Albert Callarisa <albert@diagrid.io>
Copy link
Contributor

@marcduiker marcduiker left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@alicejgibbons alicejgibbons left a comment

Choose a reason for hiding this comment

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

Thanks @acroca

@alicejgibbons alicejgibbons merged commit bd338bc into dapr:release-1.17 Feb 13, 2026
6 of 7 checks passed
@acroca acroca deleted the workflow-versioning branch February 16, 2026 14:31
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.

3 participants