-
Notifications
You must be signed in to change notification settings - Fork 135
Workflow Authoring #559
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
Workflow Authoring #559
Conversation
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #559 +/- ##
==========================================
+ Coverage 89.59% 89.60% +0.01%
==========================================
Files 62 72 +10
Lines 2978 3310 +332
==========================================
+ Hits 2668 2966 +298
- Misses 310 344 +34
|
Removing DRAFT label from PR, but I still need to check-in test cases for it, add remaining client APIs and also see how I can remove get-pip.py. |
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
@@ -0,0 +1 @@ | |||
dapr-ext-workflow==1.5.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dapr-ext-workflow==1.5.0 | |
dapr-ext-workflow-dev==0.0.1-rc.1 |
Where did you come up with this version? :D That will not be the version number we are using.
What version would you like to launch the SDK with? I would assume 0.1.0?
In the master branch we always import our development packages -- so use the -dev
one. In the release branches we then remove the -dev
suffix to refer to the stable packages. The -dev
one is the builds from master that we constantly update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you are correct. I don't know how I wrote this number here :)
Will fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to 0.0.1rc1
as per version.py of dapr-ext-workflow
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
examples/demo_workflow/app.py
Outdated
daprOptions.register_activity(hello_act) | ||
daprOptions.run() | ||
|
||
client = WorkflowClient("localhost","4001") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this port 4001? Where is this configured? Why this port?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DeepanshuA let's remove the explicit port configuration from this example. The default value of DAPR_GRPC_PORT
will be what most users want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use DAPR_GRPC_PORT. If that is not found, then "4001" is used.
Used "4001" due to https://github.com/microsoft/durabletask-python/blob/dcf205831124d82ca3886e5dba26d8c7a9ac8d73/durabletask/internal/shared.py#L18
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
examples/demo_workflow/app.py
Outdated
daprOptions.register_activity(hello_act) | ||
daprOptions.run() | ||
|
||
client = WorkflowClient("localhost","4001") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DeepanshuA let's remove the explicit port configuration from this example. The default value of DAPR_GRPC_PORT
will be what most users want.
@@ -0,0 +1,47 @@ | |||
from typing import Callable, TypeVar, Union |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the copyright header to all these files you're adding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
host = settings.DAPR_RUNTIME_HOST | ||
if port is None: | ||
port = settings.DAPR_GRPC_PORT | ||
address = f"{host}:{port}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's raise an error if either host
or port
is still None
even after running through this logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to set "host" to localhost
, if DAPR_RUNTIME_HOST is not found.
Updated to raise an error, if DAPR_GRPC_PORT is not found.
@@ -25,6 +25,7 @@ packages = find_namespace: | |||
include_package_data = True | |||
install_requires = | |||
dapr-dev >= 1.9.0rc1.dev | |||
durabletask >= 0.1.0a2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to update this again after your latest fix to make durabletask-python
compatible with 3.7 or does this version already have that support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it seems you need to release 0.1.0a3 and then update this here. The version with 3.7 compatibility has not been released yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.1.0a2 durabletask-python also has 3.7 support. But, had marked 0.1.0a3 in durabletask-python, as wanted to keep Pypi and source code on github in sync. As, 0.1.0a2 had Pypi support even when 3.7 compliant PR was not merged.
Need to automate the release process in durabletask-python, I think then this mis-match issue will not be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I'm very confused how WorkflowClient
here overlaps with Ryan's PR for workflow management.
I assume in this PR it is more of a WorkflowHost or WorkflowServer which the Dapr sidecar calls into?
If this understanding is correct, can we please avoid calling the class WorkflowClient
?
OrchestratorClient or WorkflowEngineClient or WorkflowEngineCallbackClient or something like that makes more sense to me. I assume this is how the sidecar tells your workflow to execute certain operations like pause, start, resume etc
|
||
|
||
class WorkflowRuntimeOptions: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a doc string. It's not apparent to me what this class is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed it to WorkflowRuntime
and provided a doc string.
Hmm or instead of Anything but |
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
tox.ini
Outdated
; ./validate.sh demo_actor | ||
./validate.sh demo_workflow | ||
./validate.sh invoke-binding | ||
./validate.sh grpc_proxying | ||
./validate.sh w3c-tracing | ||
./validate.sh distributed_lock | ||
./validate.sh configuration | ||
; ./validate.sh configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to leave these commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, these tests are failing with 1.10.x Dapr version. These should be fixed with 1.11.x version though, So, will remove these commented outs, once 1.11.x can be pinned and validation can run against them.
@cgillum @berndverst Please re-review this PR. I have tried to address comments and included validate example for workflow as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few additional comments from me. Note that I didn't spend much time on the test-related files since I don't really understand how the mocking works (and I'm assuming it's not something requiring critical review).
examples/demo_workflow/app.py
Outdated
from dapr.ext.workflow.workflow_runtime import WorkflowRuntime | ||
from dapr.ext.workflow.dapr_workflow_client import DaprWorkflowClient | ||
from dapr.ext.workflow.dapr_workflow_context import DaprWorkflowContext | ||
from dapr.ext.workflow.workflow_activity_context import WorkflowActivityContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need so many modules or could we reduce it down to just one or two? Note that we don't need to organize files the same way we do for .NET. Ideally we could just do something like:
from dapr.ext.workflow import DaprWorkflowClient, DaprWorkflowContext, WorkflowActivityContext, WorkflowRuntime
...or...
import dapr.ext.workflow as wf
And just refer to everything from the wf.
prefix, like wf.DaprWorkflowContext
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could import those into dapr.ext.workflow's init.py exactly as the code about so they could be imported as you mentioned. Agree it would make the existing and future code simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Please check now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In recent validate examples, somehow import in app.py is failing.
Everything seems working on my local though.
https://github.com/dapr/python-sdk/actions/runs/5020485194/jobs/9001991467#step:17:279
trying to understand that what can be the issue, is somehow dapr-ext-workflow build used in validate examples, not consisting of my init.py changes
@berndverst Any suggestions here?
if port is None: | ||
port = settings.DAPR_GRPC_PORT | ||
if port is None: | ||
raise ValueError("Port cannot be empty, please set DAPR_GRPC_PORT environment variable") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no port is specified, let's default to 50001
. This is the documented default port for gRPC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, in global_settings.py
, DAPR_GRPC_PORT is already defined to its default: https://github.com/dapr/python-sdk/blob/master/dapr/conf/global_settings.py#L24
So, it is just an extra check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, my bad. It might actually be better to remove the check to avoid confusion. Too much defense in depth can be misleading.
examples/demo_workflow/README.md
Outdated
|
||
dapr run --app-id orderapp --app-protocol grpc --dapr-grpc-port 4001 --components-path components --placement-host-address localhost:50005 -- python3 app.py | ||
``` | ||
|
||
<!-- END_STEP --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this into a separate section, named "Running this example".
dapr run --app-id orderapp --app-protocol grpc --dapr-grpc-port 4001 --components-path components --placement-host-address localhost:50005 -- python3 app.py | |
``` | |
<!-- END_STEP --> | |
<!-- END_STEP --> | |
## Running this example | |
To run this example, the following code can be utilized: | |
```bash | |
dapr run --app-id orderapp --app-protocol grpc --dapr-grpc-port 4001 --components-path components --placement-host-address localhost:50005 -- python3 app.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we need some validation on the execution of this workflow, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, app.py has got some required assertions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, added expected_stdout_lines
in Readme itself.
ext/dapr-ext-workflow/dapr/ext/workflow/dapr_workflow_client.py
Outdated
Show resolved
Hide resolved
ext/dapr-ext-workflow/dapr/ext/workflow/dapr_workflow_client.py
Outdated
Show resolved
Hide resolved
ext/dapr-ext-workflow/dapr/ext/workflow/dapr_workflow_client.py
Outdated
Show resolved
Hide resolved
ext/dapr-ext-workflow/dapr/ext/workflow/dapr_workflow_client.py
Outdated
Show resolved
Hide resolved
ext/dapr-ext-workflow/dapr/ext/workflow/workflow_activity_context.py
Outdated
Show resolved
Hide resolved
ext/dapr-ext-workflow/dapr/ext/workflow/workflow_activity_context.py
Outdated
Show resolved
Hide resolved
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: Bernd Verst <github@bernd.dev>
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
Let's see if the ordering works 👀 - that should give placement service plenty of time to initialize |
surprisingly, it still failed - don't know if placement goes in unstable state in-between due to raft election etc. |
Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I verified this locally. I will merge this now - but if we find an issue, please be prepared to create a follow up PR.
Description
This PR implements Workflow Authoring part.
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR is related to: #542
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: