Skip to content

Conversation

@passuied
Copy link
Contributor

@passuied passuied commented Nov 4, 2025

Description

Added async workflow client implementation, leveraging new durabletask.aio.client implementation

Issue reference

#834

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation (examples/workflows/simple_aio.py)

@passuied passuied requested review from a team as code owners November 4, 2025 23:31
…k.aio.client implementation

Signed-off-by: Patrick Assuied <patrick.assuied@elationhealth.com>
@passuied passuied force-pushed the feature/async-workflow-sdk branch from d32c9aa to d17b262 Compare November 4, 2025 23:31
Signed-off-by: Patrick Assuied <patrick.assuied@elationhealth.com>
@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 94.39252% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.49%. Comparing base (bffb749) to head (75f3e7c).
⚠️ Report is 48 commits behind head on main.

Files with missing lines Patch % Lines
...workflow/dapr/ext/workflow/aio/workflow_runtime.py 80.00% 11 Missing ⚠️
...flow/dapr/ext/workflow/aio/dapr_workflow_client.py 93.33% 4 Missing ⚠️
...pr-ext-workflow/tests/aio/test_workflow_runtime.py 98.30% 2 Missing ⚠️
...apr-ext-workflow/tests/aio/test_workflow_client.py 98.82% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #861      +/-   ##
==========================================
+ Coverage   86.63%   87.49%   +0.86%     
==========================================
  Files          84       98      +14     
  Lines        4473     6484    +2011     
==========================================
+ Hits         3875     5673    +1798     
- Misses        598      811     +213     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@acroca
Copy link
Member

acroca commented Nov 5, 2025

@passuied I think this other PR covers this same thing, and is a bit more complete because it also have async context, but it's WIP as it has lots of lint changes that are now applied to main. I'll ask for a cleanup. Can you have a look at that PR and confirm it'd work for you after the cleaning? focus on the ext/dapr-ext-workflow changes :)

@filintod
Copy link
Contributor

filintod commented Nov 10, 2025

@acroca actually this is a bit different, as this tackles the client initiating actions against a workflow(schedule workflow, signal events), instead of the internals of the workflow that my PR tackles. He did the PR in durabletask that complements this dapr/durabletask-python#17. The PRs his/mine are complementary and not overlapping

Copy link
Member

@acroca acroca left a comment

Choose a reason for hiding this comment

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

Looks good, but I'd follow the same pattern as the DaprClient and not have a suffix Async for the async version.

Signed-off-by: Patrick Assuied <patrick.assuied@elationhealth.com>
@passuied passuied requested a review from acroca November 11, 2025 18:20
@acroca
Copy link
Member

acroca commented Nov 12, 2025

@passuied Can you add an example to examples/workflow that uses this new client? Maybe something like https://github.com/dapr/python-sdk/blob/main/examples/workflow/simple.py but async.
Sorry for adding new items to the review, but I didn't think about it when I reviewed yesterday 🤦

passuied and others added 2 commits November 16, 2025 13:56
- Created an async version of `WorkflowRuntime` that takes event_loop as a param.

Signed-off-by: Patrick Assuied <patrick.assuied@elationhealth.com>
Signed-off-by: Albert Callarisa <albert@diagrid.io>
Copy link
Member

@acroca acroca left a comment

Choose a reason for hiding this comment

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

LGTM, but tests are failing, and copyright headers need to be fixed :)

- Updated simple-aio to show examples of async and sync activities

Signed-off-by: Patrick Assuied <patrick.assuied@elationhealth.com>
@passuied passuied requested a review from acroca November 17, 2025 16:10
Signed-off-by: Patrick Assuied <patrick.assuied@elationhealth.com>
@passuied passuied requested a review from acroca November 17, 2025 16:18
Signed-off-by: Patrick Assuied <patrick.assuied@elationhealth.com>
… works regardless of how we register it...

Signed-off-by: Patrick Assuied <patrick.assuied@elationhealth.com>

@wraps(fn)
def target_fn():
return fn

Choose a reason for hiding this comment

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

  1. Does this mean that if the main_event_loop was not provided in the constructor, we'll silently treat all activities as synchronous? If this is the case, should we make main_event_loop required? Otherwise, it seems to be defeating the purpose. Or am I missing something?
  2. Isn't it supposed to call fn() instead of returning the function itself?

reuse_id_policy=reuse_id_policy,
)
return await self.__obj.schedule_new_orchestration(
workflow.__name__,

Choose a reason for hiding this comment

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

Minor - consider storing the workflow.__dict__['_dapr_alternate_name'] / workflow.__name__ in a variable and avoiding code duplication around calling self.__obj.schedule_new_orchestration

]


class WorkflowRuntime(WorkflowRuntimeSync):

Choose a reason for hiding this comment

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

I'm not sure if wrapping the sync runtime is the best course of action here. Instead, it should be natively supported by durabletask it looks like there's been a lot of work, including async support done there. Are you sure it's not already a resolved problem?

Copy link
Contributor Author

@passuied passuied Nov 18, 2025

Choose a reason for hiding this comment

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

@akotsarelation I agree that when I look at @filintod's PR, I'm inclined to wait for his work to be complete so we can replace the whole WorkflowRuntime with his full async implementation...
It wasn't so apparent until I worked on the example @acroca and I had to override WorkflowRuntime (but not in an ideal way as I still need the work from that PR)... While the current solution works it does mix sync and async and comes with performance downsides... If this PR is coming soon, I'm inclined to not publish this one and instead wait for the full blown solution....

Copy link
Contributor

@filintod filintod Nov 19, 2025

Choose a reason for hiding this comment

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

I guess the issue is that you were changing not only the client side (dapr_workflow_client) but also the workflowruntime, that yeah you would need something like what I am doing. Was that needed here? as your durabletask PR only dealt with the client side (schedule workflow, etc) and why I said this PR and the durabletask were complementary but not if mixing workflow runtime too.

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.

4 participants