From 15e59e95ddb29fb013b67f83777eb722ab2c6869 Mon Sep 17 00:00:00 2001 From: Stephen Barlow Date: Fri, 20 Feb 2026 11:40:20 -0800 Subject: [PATCH] Update for SDK 0.3.x --- README.md | 4 +++- main.py | 26 +++++++++++++------------- requirements.txt | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d3f3fbf..d51d28b 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/main.py b/main.py index b665e48..40d4317 100644 --- a/main.py +++ b/main.py @@ -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), @@ -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: @@ -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 diff --git a/requirements.txt b/requirements.txt index 22985ed..643a56b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -render_sdk==0.1.1 +render_sdk==0.3.0