Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions exercises/debug-activity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ does by using the Web UI to interpret the Event History.

Open the Web UI and navigate to the detail page for the Workflow
Execution you just ran, which has the Workflow Type `PizzaWorkflow`
and Workflow ID `pizza-workflow-order-XD001`).
and Workflow ID `pizza-workflow-order-XD001`.

If the detail page still shows a status of Running, wait a few seconds
and refresh the page. Once the page shows a status of Completed, use
Expand Down Expand Up @@ -87,7 +87,7 @@ Take a moment to switch to the Compact view, and if one of the rows in the
table is expanded, click to collapse it. Do you find that this view makes
it easier to see the Activities and Timer that ran during the execution?

Click "Expand All" near the upper-right corner of this table. Do you find
Click "Expand All" at the top of this table. Do you find
that this helps you to correlate Events related to the Activities and Timer?

Since the Web UI remembers the current view, be sure to click "Collapse All"
Expand Down Expand Up @@ -178,7 +178,7 @@ in the Workflow code, rather than in an Activity, since that is typically
not prone to failure and unlikely to affect whether the Workflow executes
in a deterministic manner. This exercise implemented it in the Activity,
since you can deploy a fix to Activity code without a risk of causing a
non-deterministic error. Later in this course, you'll learn how to safely
non-deterministic error. As you learned earlier in this course, there are also ways to safely
Copy link
Contributor Author

@GSmithApps GSmithApps Jan 8, 2025

Choose a reason for hiding this comment

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

I think the course order has changed because when I just took it, the non-determinism stuff was before this

deploy changes to Workflow Definitions.

### This is the end of the exercise.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def test_send_bill_typical_order():
customer_id=12983,
order_number="XD001",
description="2 large cheese pizzas",
amount=2600,
amount=2600, # amount does not qualify for discount
)
activity_environment = ActivityEnvironment()
activities = PizzaOrderActivities()
Expand Down
5 changes: 4 additions & 1 deletion exercises/durable-execution/practice/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class TranslationWorkflow:

workflow.logger.workflow_info_on_message = False
workflow.logger.workflow_info_on_extra = False
#workflow.logger.workflow_info_on_extra = False

@workflow.run
async def run(self, input: TranslationWorkflowInput) -> TranslationWorkflowOutput:
Expand All @@ -44,11 +44,14 @@ async def run(self, input: TranslationWorkflowInput) -> TranslationWorkflowOutpu

# TODO PART D:Add a Timer that sleeps for 10 seconds


# TODO PART A:Add a log message using the workflow logger at the debug level
# stating that the Activity has been invoked. Include the term and language code.

goodbye_input = TranslationActivityInput(
language_code=input.language_code, term="goodbye"
)

goodbye_result = await workflow.execute_activity_method(
TranslationActivities.translate_term,
goodbye_input,
Expand Down
4 changes: 2 additions & 2 deletions exercises/durable-execution/solution/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
class TranslationWorkflow:

workflow.logger.workflow_info_on_message = False
workflow.logger.workflow_info_on_extra = False
#workflow.logger.workflow_info_on_extra = False

@workflow.run
async def run(self, input: TranslationWorkflowInput) -> TranslationWorkflowOutput:
workflow.logger.info(f"tTranslationWorkflow invoked with {input}")
workflow.logger.info(f"TranslationWorkflow invoked with {input}")

hello_input = TranslationActivityInput(
language_code=input.language_code, term="hello"
Expand Down
8 changes: 5 additions & 3 deletions exercises/testing-code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ test, which you'll find in the `test_activities.py` file in the `tests` director
Since the test runs the Activity, which in turn calls the microservice to do
the translation, you'll begin by starting that.

1. Run the `python -m pytest` command to execute the provided test
1. Navigate to `exercises/testing-code/practice`
2. Run the `python -m pytest` command to execute the provided test

## Part B: Add another test case for the Activity

Expand Down Expand Up @@ -136,11 +137,12 @@ continue with the following steps.
```
4. Create a new async function to mock your Activity.
1. Name it `translate_term_mocked_french` and decorate it with
`@activity.defn(name="translate_term")`. The function should take `TranslationActivityInput`
`@activity.defn(name="translate_term")`. The function's signature should
match that of the activity it is mocking.
2. In the body of your new mocked Activity, write an if statement that returns
a new `TranslationActivityOutput` object containing `Bonjour` if the term
that was passed in via the `TranslationActivityInput` was `hello`. Otherwise
return a new `TranslationActivityObject` containing `Au revoir`.
return a new `TranslationActivityOutput` containing `Au revoir`.
3. The full mocked Activity is shown below:
```python
@activity.defn(name="translate_term")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pluggy==1.5.0
protobuf==5.27.0
pytest==8.2.2
pytest-asyncio==0.23.7
temporalio==1.6.0
temporalio==1.10.0
types-protobuf==5.26.0.20240422
typing_extensions==4.12.1
Werkzeug==3.0.3
Expand Down