Skip to content

Commit cce9474

Browse files
Merge pull request #296 from runpod/1.6.1-cleanup
1.6.1 cleanup
2 parents 9e11c99 + 01a613c commit cce9474

File tree

2 files changed

+123
-21
lines changed

2 files changed

+123
-21
lines changed

CHANGELOG.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
# Change Log
22

3-
## Release 1.6.1 (TBD)
3+
## Release 1.6.1 (2/11/24)
44

55
### Added
66

77
- User-Agent for better analytics tracking.
8+
- Expose the ability to create container auth.
9+
- Emulate webhooks for local testing when using `rp_serve_api` flag.
10+
11+
### Changed
12+
13+
- Updated aiohttp from 3.9.2 to 3.9.3
14+
- [BREAKING] rename `registry_auth` to `registry_auth_id` for clarity.
15+
- Added additional details to the FastAPI page.
16+
17+
---
818

919
## Release 1.6.0 (1/29/24)
1020

@@ -14,6 +24,8 @@
1424
- GitHub Action and Python package updates
1525
- Changelog date typo
1626

27+
---
28+
1729
## Release 1.5.3 (1/25/24)
1830

1931
### Added
@@ -27,6 +39,8 @@
2739

2840
- ReadMe typo *start_pod* -> *resume_pod*
2941

42+
---
43+
3044
## Release 1.5.2 (1/16/24)
3145

3246
### Fixed
@@ -40,6 +54,8 @@
4054

4155
- Expanded RunPod Serverless Core testing.
4256

57+
---
58+
4359
## Release 1.5.1 (1/11/24)
4460

4561
### Fixed
@@ -52,6 +68,8 @@
5268

5369
- Updated sls-core to `0.0.2`
5470

71+
---
72+
5573
## Release 1.5.0 (12/28/23)
5674

5775
### Added

runpod/serverless/modules/rp_fastapi.py

+104-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
''' Used to launch the FastAPI web server when worker is running in API mode. '''
2-
# pylint: disable=too-few-public-methods
2+
# pylint: disable=too-few-public-methods, line-too-long
33

44
import os
55
import uuid
@@ -22,21 +22,82 @@
2222

2323
RUNPOD_ENDPOINT_ID = os.environ.get("RUNPOD_ENDPOINT_ID", None)
2424

25+
TITLE = "RunPod | Development Worker API"
26+
2527
DESCRIPTION = """
26-
This API server is provided as a method of testing and debugging your worker locally.
27-
Additionally, you can use this to test code that will be making requests to your worker.
28+
The Development Worker API facilitates testing and debugging of your RunPod workers.
29+
It offers a sandbox environment for executing code and simulating interactions with your worker, ensuring your applications can seamlessly transition to production on RunPod serverless platform.
30+
Use this API for comprehensive testing of request submissions and result retrieval, mimicking the behavior of RunPod's operational environment.
31+
---
32+
*Note: This API serves as a local testing tool and will not be utilized once your worker is operational on the RunPod platform.*
33+
"""
2834

29-
### Endpoints
35+
# Add CLI tool suggestion if RUNPOD_PROJECT_ID is not set.
36+
if os.environ.get("RUNPOD_PROJECT_ID", None) is None:
37+
DESCRIPTION += """
3038
31-
The URLs provided are named to match the endpoints that you will be provided when running on RunPod.
39+
ℹ️ | Consider developing with our CLI tool to streamline your worker development process.
3240
33-
---
41+
>_ wget -qO- cli.runpod.net | sudo bash
42+
>_ runpodctl project create
43+
"""
44+
45+
RUN_DESCRIPTION = """
46+
Initiates processing jobs, returning a unique job ID.
47+
48+
**Parameters:**
49+
- **input** (string): The data to be processed by the worker. This could be a string, JSON object, etc., depending on the worker's requirements.
50+
- **webhook** (string, optional): A callback URL for result notification upon completion. If specified, the server will send a POST request to this URL with the job's result once it's available.
3451
35-
*Note: When running your worker on the RunPod platform, this API server will not be used.*
52+
**Returns:**
53+
- **job_id** (string): A unique identifier for the job, used with the `/stream` and `/status` endpoints for monitoring progress and checking job status.
3654
"""
3755

38-
job_list = Jobs()
56+
RUNSYNC_DESCRIPTION = """
57+
Executes processing jobs synchronously, returning the job's output directly.
58+
59+
This endpoint is ideal for tasks where immediate result retrieval is necessary,
60+
streamlining the execution process by eliminating the need for subsequent
61+
status or result checks.
62+
63+
**Parameters:**
64+
- **input** (string): The data to be processed by the worker. This should be in a format that the worker can understand (e.g., JSON, text, etc.).
65+
- **webhook** (string, optional): A callback URL to which the result will be posted. While direct result retrieval is the primary operation mode for this endpoint, specifying a webhook allows for asynchronous result notification if needed.
66+
67+
**Returns:**
68+
- **output** (Any): The direct output from the processing job, formatted according to the job's nature and the expected response structure. This could be a JSON object, plain text, or any data structure depending on the processing logic.
69+
"""
70+
71+
STREAM_DESCRIPTION = """
72+
Continuously aggregates the output of a processing job, returning the full output once the job is complete.
3973
74+
This endpoint is especially useful for jobs where the complete output needs to be accessed at once. It provides a consolidated view of the results post-completion, ensuring that users can retrieve the entire output without the need to poll multiple times or manage partial results.
75+
76+
**Parameters:**
77+
- **job_id** (string): The unique identifier of the job for which output is being requested. This ID is used to track the job's progress and aggregate its output.
78+
79+
**Returns:**
80+
- **output** (Any): The aggregated output from the job, returned as a single entity once the job has concluded. The format of the output will depend on the nature of the job and how its results are structured.
81+
"""
82+
83+
STATUS_DESCRIPTION = """
84+
Checks the completion status of a processing job and returns its output if the job is complete.
85+
86+
This endpoint is invaluable for monitoring the progress of a job and obtaining the output only after the job has fully completed. It simplifies the process of querying job completion and retrieving results, eliminating the need for continuous polling or result aggregation.
87+
88+
**Parameters:**
89+
- **job_id** (string): The unique identifier for the job being queried. This ID is used to track and assess the status of the job.
90+
91+
**Returns:**
92+
- **status** (string): The completion status of the job, typically 'complete' or 'in progress'. This status indicates whether the job has finished processing and if the output is ready for retrieval.
93+
- **output** (Any, optional): The final output of the job, provided if the job is complete. The format and structure of the output depend on the job's nature and the data processing involved.
94+
95+
**Note:** The availability of the `output` field is contingent on the job's completion status. If the job is still in progress, this field may be omitted or contain partial results, depending on the implementation.
96+
"""
97+
98+
99+
# ------------------------------ Initializations ----------------------------- #
100+
job_list = Jobs()
40101
heartbeat = Heartbeat()
41102

42103

@@ -124,12 +185,28 @@ def __init__(self, config: Dict[str, Any]):
124185

125186
self.config = config
126187

188+
tags_metadata = [
189+
{
190+
"name": "Submit Job Requests",
191+
"description": "Endpoints for submitting job requests."
192+
},
193+
{
194+
"name": "Check Job Results",
195+
"description": "Endpoints for checking the status of a job and getting the results."
196+
},
197+
{
198+
"name": "Synchronously Submit Request & Get Job Results",
199+
"description": "Endpoints for submitting job requests and getting the results."
200+
}
201+
]
202+
127203
# Initialize the FastAPI web server.
128204
self.rp_app = FastAPI(
129-
title="RunPod | Test Worker | API",
205+
title=TITLE,
130206
description=DESCRIPTION,
131207
version=runpod_version,
132-
docs_url="/"
208+
docs_url="/",
209+
openapi_tags=tags_metadata
133210
)
134211

135212
# Create an APIRouter and add the route for processing jobs.
@@ -148,23 +225,30 @@ def __init__(self, config: Dict[str, Any]):
148225
# Simulation endpoints.
149226
api_router.add_api_route(
150227
"/run", self._sim_run, methods=["POST"], response_model_exclude_none=True,
151-
summary="Simulate run behavior.",
152-
description="Returns job ID to be used with `/stream` and `/status` endpoints."
228+
summary="Mimics the behavior of the run endpoint.",
229+
description=RUN_DESCRIPTION,
230+
tags=["Submit Job Requests"]
153231
)
154232
api_router.add_api_route(
155-
"/runsync", self._sim_runsync, methods=["POST"], response_model_exclude_none=True,
156-
summary="Simulate runsync behavior.",
157-
description="Returns job output directly when called."
233+
"/runsync", self._sim_runsync, methods=["POST"],
234+
response_model_exclude_none=True,
235+
summary="Mimics the behavior of the runsync endpoint.",
236+
description=RUNSYNC_DESCRIPTION,
237+
tags=["Synchronously Submit Request & Get Job Results"]
158238
)
159239
api_router.add_api_route(
160-
"/stream/{job_id}", self._sim_stream, methods=["POST", "GET"],
161-
response_model_exclude_none=True, summary="Simulate stream behavior.",
162-
description="Aggregates the output of the job and returns it when the job is complete."
240+
"/stream/{job_id}", self._sim_stream, methods=["POST"],
241+
response_model_exclude_none=True,
242+
summary="Mimics the behavior of the stream endpoint.",
243+
description=STREAM_DESCRIPTION,
244+
tags=["Check Job Results"]
163245
)
164246
api_router.add_api_route(
165247
"/status/{job_id}", self._sim_status, methods=["POST"],
166-
response_model_exclude_none=True, summary="Simulate status behavior.",
167-
description="Returns the output of the job when the job is complete."
248+
response_model_exclude_none=True,
249+
summary="Mimics the behavior of the status endpoint.",
250+
description=STATUS_DESCRIPTION,
251+
tags=["Check Job Results"]
168252
)
169253

170254
# Include the APIRouter in the FastAPI application.

0 commit comments

Comments
 (0)