Skip to content

Commit

Permalink
Fix Python basics examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tillrohrmann committed Feb 19, 2025
1 parent a22d19e commit ac0be54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions python/basics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The examples here showcase the most basic building blocks of Restate. **Durable
of them.

The individual example files contain code snippets with comments and a brief descriptions
about how they work and how they can be run.
about how they work and how they can be run.

### Examples

Expand All @@ -24,7 +24,7 @@ about how they work and how they can be run.
* **[Workflows](app/3_workflows.py):** Workflows are durable execution tasks that can
be submitted and awaited. They have an identity and can be signaled and queried
through durable promises. The example is a user-signup flow that takes multiple
operations, including verifying the email address.
operations, including verifying the email address.


### Running the examples
Expand All @@ -39,7 +39,7 @@ To set up the example, use the following sequence of commands.
```

3. Start the app as follows:
- Durable execution example: `python -m hypercorn --config hypercorn-config.toml app/1_durable_execution.py:app`
- Durable execution example: `python -m hypercorn --config hypercorn-config.toml app/0_durable_execution.py:app`
- The building blocks example is not runnable and more like a reference of what you can do with the API
- Virtual Objects example: `python -m hypercorn --config hypercorn-config.toml app/2_virtual_objects.py:app`
- Workflows example: `python -m hypercorn --config hypercorn-config.toml app/3_workflows.py:app`
Expand Down
14 changes: 8 additions & 6 deletions python/basics/app/3_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ async def click(ctx: WorkflowSharedContext, secret: str):
app = restate.app(services=[user_signup])

"""
You can deploy this as a container, Lambda, etc. - Invoke it over HTTP via: curl
localhost:8080/usersignup/signup-userid1/run/send -H 'content-type: application/json' \
-d '{ "name": "Bob", "email": "[email protected]" }'
You can deploy this as a container, Lambda, etc. - Invoke it over HTTP via:
curl localhost:8080/usersignup/signup-userid1/run/send -H 'content-type: application/json' -d '{ "name": "Bob", "email": "[email protected]" }'
- Resolve the email link via:
curl localhost:8080/usersignup/signup-userid1/verifyEmail
curl localhost:8080/usersignup/signup-userid1/click -H 'content-type: application/json' -d '"<SECRET>"'
- Attach back to the workflow to get the result:
curl localhost:8080/restate/workflow/usersignup/userid1/attach
"""
curl localhost:8080/restate/workflow/usersignup/signup-userid1/attach
"""
2 changes: 1 addition & 1 deletion python/basics/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def create_user_entry(user):
def send_email_with_link(user_id: str, email: str, secret: str):
print(f"Sending email to {email} with secret {secret}. \n"
f"To simulate a user clicking the link, run the following command: \n"
f"curl localhost:8080/usersignup/{user_id}/click -H 'content-type: application/json' -d '{{ \"secret\": \"{secret}\"}}'")
f"curl localhost:8080/usersignup/{user_id}/click -H 'content-type: application/json' -d '\"{secret}\"'")


async def charge_bank_account(payment_deduplication_id: str, amount: int) -> bool:
Expand Down

0 comments on commit ac0be54

Please sign in to comment.