-
Notifications
You must be signed in to change notification settings - Fork 32
docs: Update Flash local testing docs with request format and docstring feature #564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,25 @@ Enable or disable auto-reload on code changes. Enabled by default. | |
| Auto-provision all Serverless endpoints on startup instead of lazily on first call. Eliminates cold-start delays during development. | ||
| </ResponseField> | ||
|
|
||
| ## Endpoint descriptions from docstrings | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Citation: PR #215 introduces |
||
|
|
||
| Flash extracts the first line of each function's docstring and uses it in two places: | ||
|
|
||
| - **Startup table**: The "Description" column shows the docstring when the server starts. | ||
| - **Swagger UI**: The endpoint summary in the API explorer at `/docs`. | ||
|
|
||
| Add docstrings to your `@Endpoint` functions to make your API self-documenting: | ||
|
|
||
| ```python | ||
| @Endpoint(name="text-processor", gpu=GpuGroup.ANY) | ||
| def analyze_text(text: str) -> dict: | ||
| """Analyze text and return sentiment scores.""" | ||
| # Implementation here | ||
| return {"sentiment": "positive"} | ||
| ``` | ||
|
|
||
| When you run `flash run`, the startup table displays "Analyze text and return sentiment scores" as the description for this endpoint, and the same text appears in the Swagger UI summary. | ||
|
|
||
| ## Architecture | ||
|
|
||
| With `flash run`, Flash starts a local development server alongside remote Serverless endpoints: | ||
|
|
@@ -136,14 +155,18 @@ curl http://localhost:8888/ | |
| # Call a queue-based GPU endpoint (gpu_worker.py) | ||
| curl -X POST http://localhost:8888/gpu_worker/runsync \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{"message": "Hello from GPU!"}' | ||
| -d '{"input": {"message": "Hello from GPU!"}}' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Citation: PR #215 introduces |
||
|
|
||
| # Call a load-balanced endpoint (lb_worker.py) | ||
| curl -X POST http://localhost:8888/lb_worker/process \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{"data": "test"}' | ||
| ``` | ||
|
|
||
| <Note> | ||
| Queue-based endpoints require the `{"input": {...}}` wrapper format to match deployed endpoint behavior. Load-balanced endpoints accept direct JSON payloads. | ||
| </Note> | ||
|
|
||
| Open http://localhost:8888/docs for the interactive API explorer. | ||
|
|
||
| ## Requirements | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Citation: PR #215 adds docstring extraction via
RemoteFunctionMetadata.docstringinscanner.pyand displays it inrun.py's startup table and Swagger UI summary using_escape_summary()helper.View source