Skip to content

docs(examples): fix broken and stale examples - #694

Open
deanq wants to merge 2 commits into
mainfrom
deanq/sls-1000-fix-examples
Open

deanq wants to merge 2 commits into
mainfrom
deanq/sls-1000-fix-examples

Conversation

@deanq

@deanq deanq commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

What

Fixes the examples under examples/api, examples/endpoints, examples/serverless, and examples/rest_wrapper.py. examples/apps is unchanged: it matches the current SDK, and #557 already touches it.

File Problem Fix
endpoints/asyncio_job_request.py Unconditional asyncio.WindowsSelectorEventLoopPolicy() raises AttributeError on macOS and Linux. await job.output() with the default timeout raises TimeoutError immediately on current releases (SDK fix in #662). Remove the policy line. Pass an explicit timeout= to job.output().
api/create_endpoint.py runpod/base:0.4.4 does not exist on Docker Hub. Use runpod/mock-worker:latest, a real serverless worker.
api/create_template.py Very old runpod/base:0.1.0. runpod/base:2.0.0-ubuntu2404.
api/*, endpoints/* Comments point to runpod config, which no longer exists. Point to rp login.
endpoints/run_sync.py except TimeoutError misses requests.exceptions.Timeout, which is raised when the HTTP wait exceeds timeout. Catch both.
serverless/logger.py Documented output matched neither local nor deployed output. Document both: plain text locally, JSON when RUNPOD_ENDPOINT_ID is set.
serverless/concurrent_handler.py Handler named async_generator_handler was not a generator; the modifier was a no-op. A real async handler and a modifier that returns a set concurrency.
rest_wrapper.py Used stop_pod's response for the pod id. Keep the id from create_pod. Describe what the script does.
endpoints/health.py, run.py, run_sync.py, streaming.py Hardcoded endpoint ids. streaming.py sent mock-worker-only input without saying so. YOUR_ENDPOINT_ID placeholders; note which worker the streaming input targets.

Second commit: new-user pass

  • examples/README.md (new): prerequisites, which folder to start with, running handlers locally, getting an endpoint id, cost and cleanup. The top-level README's Examples link now points here instead of examples/apps.
  • api/*: unique names (re-running no longer collides on template names), cleanup commands, placeholder registry credentials. get_endpoints.py prints ids and names instead of every endpoint's full config, including env.
  • endpoints/run.py: waits with a timeout. The bare output() call printed None while the job was queued.
  • rest_wrapper.py: terminates the pod in finally, so a failed resume doesn't leave a billable pod running.

Why

None of these files run in CI, so they had drifted from the SDK. Running examples in CI is tracked separately.

Test plan

  • make quality-check (2773 passed)
  • serverless/logger.py: output matches the comments, both locally and with RUNPOD_ENDPOINT_ID set
  • serverless/concurrent_handler.py and simple_handler.py with --test_input
  • endpoints/asyncio_job_request.py, run.py, run_sync.py, health.py, streaming.py against a local fake API (RUNPOD_ENDPOINT_BASE_URL), with jobs going from IN_PROGRESS to COMPLETED
  • Docker Hub returns the image tags used
  • endpoints/run.py (second commit) against the fake API: prints the status, then the output
  • api/* and rest_wrapper.py not run: they create billable resources. Only the signatures and the image tags were checked.

deanq added 2 commits November 7, 2026 08:43
- asyncio_job_request: drop the Windows-only event loop policy that
  raised AttributeError on macOS and Linux; pass an explicit timeout
  to job.output()
- create_endpoint: replace a base image tag that does not exist with
  runpod/mock-worker:latest; refresh the create_template base image
- replace the removed `runpod config` command with `rp login`
- run_sync: also catch requests.exceptions.Timeout
- logger: document local text output and deployed JSON output
- concurrent_handler: use a real async handler and modifier
- rest_wrapper: keep the pod id from create_pod; describe what it does
- use YOUR_ENDPOINT_ID placeholders; note the mock-worker input

SLS-1000
- examples/README.md: prerequisites, which folder to start with,
  running handlers locally, getting an endpoint id, cost and cleanup
- point the top-level README Examples link at the index
- api examples: unique names, cleanup commands, placeholder
  registry credentials; get_endpoints prints ids and names only
  instead of every endpoint's env
- endpoints/run.py: wait with a timeout instead of printing None
- rest_wrapper.py: terminate the pod in a finally block

SLS-1000
@deanq deanq changed the title docs(examples): fix broken and stale examples (SLS-1000) docs(examples): fix broken and stale examples Nov 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant