MCPcopy Create free account
hub / github.com/pytorch/tutorials / handle_request

Method handle_request

beginner_source/serving_tutorial.py:155–166  ·  view source on GitHub ↗

Handle an incoming HTTP request using FastAPI. Inputs are automatically validated using the Pydantic model.

(self, request: ImageRequest)

Source from the content-addressed store, hash-verified

153
154 @app.post("/")
155 async def handle_request(self, request: ImageRequest):
156 """Handle an incoming HTTP request using FastAPI.
157
158 Inputs are automatically validated using the Pydantic model.
159 """
160 # Process the single request.
161 image_array = np.array(request.image)
162
163 # Ray Serve's @serve.batch automatically batches requests.
164 result = await self.predict_batch(image_array)
165
166 return result
167
168
169######################################################################

Callers

nothing calls this directly

Calls 1

predict_batchMethod · 0.95

Tested by

no test coverage detected