Adding in flush statements to prints for workflow example (#873)

* Adding in flush statements to prints for workflow example

Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>

* Reverting other changes

Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>

* makiong dapr run commands align in wf readme

Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>

* Updating componnents path to resources path

Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>

---------

Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
This commit is contained in:
Ryan Lettieri 2023-06-05 18:25:07 -06:00 committed by GitHub
parent 749013825b
commit fff44b0383
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -42,7 +42,7 @@ sleep: 15
```sh
cd ./order-processor
dapr run --app-id order-processor --components-path ../../../components/ -- python3 app.py
dapr run --app-id order-processor --resources-path ../../../components/ -- python3 app.py
```
<!-- END_STEP -->
@ -81,7 +81,7 @@ For a more detailed view of the workflow activities (duration, progress etc.), t
### What happened?
When you ran `dapr run --app-id order-processor --app-protocol grpc --dapr-grpc-port 4001 --components-path ../../../components/ --placement-host-address localhost:50005 -- python3 app.py`
When you ran `dapr run --app-id order-processor --resources-path ../../../components/ -- python3 app.py`
1. First the user inputs an order for 11 cars into the concole app.
2. A unique order ID for the workflow is generated (in the above example, `b903d749cd814e099f06ebf4a56a2f90`) and the workflow is scheduled.

View File

@ -17,8 +17,8 @@ default_item_name = "cars"
class WorkflowConsoleApp:
def main(self):
print("*** Welcome to the Dapr Workflow console app sample!")
print("*** Using this app, you can place orders that start workflows.")
print("*** Welcome to the Dapr Workflow console app sample!", flush=True)
print("*** Using this app, you can place orders that start workflows.", flush=True)
# Wait for the sidecar to become available
sleep(5)
@ -39,13 +39,13 @@ class WorkflowConsoleApp:
self.restock_inventory(daprClient, baseInventory)
print("==========Begin the purchase of item:==========")
print("==========Begin the purchase of item:==========", flush=True)
item_name = default_item_name
order_quantity = 11
total_cost = int(order_quantity) * baseInventory[item_name].per_item_cost
order = OrderPayload(item_name=item_name, quantity=int(order_quantity), total_cost=total_cost)
print(f'Starting order workflow, purchasing {order_quantity} of {item_name}')
print(f'Starting order workflow, purchasing {order_quantity} of {item_name}', flush=True)
start_resp = daprClient.start_workflow(workflow_component=workflow_component,
workflow_name=workflow_name,
input=order)
@ -89,7 +89,7 @@ class WorkflowConsoleApp:
elif state.runtime_status == "Completed" or\
state.runtime_status == "Failed" or\
state.runtime_status == "Terminated":
print(f'Workflow completed! Result: {state.runtime_status}')
print(f'Workflow completed! Result: {state.runtime_status}', flush=True)
break
if time_delta.total_seconds() >= 10:
state = daprClient.get_workflow(instance_id=_id, workflow_component=workflow_component)
@ -101,7 +101,7 @@ class WorkflowConsoleApp:
approval_seeked = True
threading.Thread(target=prompt_for_approval(daprClient), daemon=True).start()
print("Purchase of item is ", state.runtime_status)
print("Purchase of item is ", state.runtime_status, flush=True)
def restock_inventory(self, daprClient: DaprClient, baseInventory):
for key, item in baseInventory.items():