Skip to content

Commit

Permalink
Merge pull request #935 from paulyuk/multiapp-wf
Browse files Browse the repository at this point in the history
Multi-run support for workflow
  • Loading branch information
paulyuk authored Sep 27, 2023
2 parents ab41de2 + 5aade01 commit 0ad816b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/env/global.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DAPR_CLI_VERSION: 1.12.0-rc.1
DAPR_RUNTIME_VERSION: 1.12.0-rc.3
DAPR_CLI_VERSION: 1.12.0-rc.2
DAPR_RUNTIME_VERSION: 1.12.0-rc.4
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v${DAPR_CLI_VERSION}/install/
DAPR_DEFAULT_IMAGE_REGISTRY: ghcr
MACOS_PYTHON_VERSION: 3.10
2 changes: 1 addition & 1 deletion workflows/components/state_redis.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore-actors
name: statestore
spec:
type: state.redis
version: v1
Expand Down
9 changes: 4 additions & 5 deletions workflows/csharp/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,17 @@ dotnet build
<!-- STEP
name: Run order-processor service
expected_stdout_lines:
- '== APP == There are now: 90 Cars left in stock'
- '== APP == Workflow Status: Completed'
- "Exited App successfully"
- "== APP - order-processor == There are now: 90 Cars left in stock"
- "== APP - order-processor == Workflow Status: Completed"
expected_stderr_lines:
output_match_mode: substring
background: true
sleep: 15
timeout_seconds: 120
-->

```bash
cd ./order-processor
dapr run --app-id order-processor dotnet run
dapr run -f .
```

<!-- END_STEP -->
Expand Down
7 changes: 7 additions & 0 deletions workflows/csharp/sdk/dapr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 1
common:
resourcesPath: ../../components
apps:
- appID: order-processor
appDirPath: ./order-processor/
command: ["dotnet", "run"]
19 changes: 13 additions & 6 deletions workflows/python/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ name: Install requirements
```sh
cd ./order-processor
pip3 install -r requirements.txt
cd ..
```

<!-- END_STEP -->
Expand All @@ -33,20 +34,17 @@ pip3 install -r requirements.txt
name: Running this example
expected_stdout_lines:
- "There are now 90 cars left in stock"
- "Purchase of item is Completed"
- "Workflow completed! Result: Completed"
output_match_mode: substring
background: true
timeout_seconds: 30
timeout_seconds: 120
sleep: 15
-->

```sh
cd ./order-processor
dapr run --app-id order-processor --resources-path ../../../components/ -- python3 app.py
dapr run -f .
```

<!-- END_STEP -->

3. Expected output

```
Expand All @@ -71,6 +69,15 @@ Workflow completed! Result: Completed
Purchase of item is Completed
```

4. Stop Dapr workflow with CTRL-C or:
<!-- END_STEP -->

```sh
dapr stop -f .
```



### View workflow output with Zipkin

For a more detailed view of the workflow activities (duration, progress etc.), try using Zipkin.
Expand Down
7 changes: 7 additions & 0 deletions workflows/python/sdk/dapr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 1
common:
resourcesPath: ../../components
apps:
- appDirPath: ./order-processor/
appID: order-processor
command: ["python3", "app.py"]
4 changes: 2 additions & 2 deletions workflows/python/sdk/order-processor/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
verify_inventory_activity, update_inventory_activity, requst_approval_activity
from model import InventoryItem, OrderPayload

store_name = "statestore-actors"
store_name = "statestore"
workflow_component = "dapr"
workflow_name = "order_processing_workflow"
default_item_name = "cars"
Expand Down Expand Up @@ -108,7 +108,7 @@ def restock_inventory(self, daprClient: DaprClient, baseInventory):
print(f'item: {item}')
item_str = f'{{"name": "{item.item_name}", "quantity": {item.quantity},\
"per_item_cost": {item.per_item_cost}}}'
daprClient.save_state("statestore-actors", key, item_str)
daprClient.save_state(store_name, key, item_str)

if __name__ == '__main__':
app = WorkflowConsoleApp()
Expand Down
2 changes: 1 addition & 1 deletion workflows/python/sdk/order-processor/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from model import InventoryItem, Notification, InventoryRequest, OrderPayload, OrderResult,\
PaymentRequest, InventoryResult

store_name = "statestore-actors"
store_name = "statestore"

logging.basicConfig(level=logging.INFO)

Expand Down

0 comments on commit 0ad816b

Please sign in to comment.