Skip to content
Open
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

Copy this template to your GitHub account by clicking **Use this template > Create a new repository**.

To get started with this template, see [Your First Workflow](https://render.com/docs/workflows-tutorial).
- **To get started with this template,** see [Your First Workflow](https://render.com/docs/workflows-tutorial).

- **To run locally,** see [Local Dev with Render Workflows](https://render.com/docs/workflows-local-development).

When deploying your copy of this template as a workflow service on Render, set the following:

Expand Down
26 changes: 13 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from render_sdk.workflows import task, start, Options, Retry
from render_sdk import Workflows, Retry
import asyncio
import random

app = Workflows()

# A minimal task definition
@task
@app.task
def calculate_square(a: int) -> int:
return a * a

# A task that runs two parallel subtasks
# (Must be async to await subtask results)
@task
# A task that chains two parallel runs
# (Must be async to await run results)
@app.task
async def sum_squares(a: int, b: int) -> int:
result1, result2 = await asyncio.gather(
calculate_square(a),
Expand All @@ -19,13 +21,11 @@ async def sum_squares(a: int, b: int) -> int:

# A task that flips a coin and retries on "tails"
# (Illustrates specifying retry logic on failure)
@task(
options=Options(
retry=Retry(
max_retries=3, # Retry up to 3 times (i.e., 4 total attempts)
wait_duration_ms=1000, # Set a base retry delay of 1 second
factor=1.5 # Increase delay by 50% after each retry (exponential backoff)
)
@app.task(
retry=Retry(
max_retries=3,
wait_duration_ms=1000,
backoff_scaling=1.5
)
)
def flip_coin() -> str:
Expand All @@ -34,4 +34,4 @@ def flip_coin() -> str:
return "Flipped heads!"

if __name__ == "__main__":
start() # SDK entry point, required for all workflow services
app.start() # SDK entry point, required for all workflow services
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
render_sdk==0.1.1
render_sdk==0.3.0