mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 11:53:32 +08:00
[Serve] Fix handle args data type issue (#10629)
This commit is contained in:
@@ -10,11 +10,11 @@ from typing import List
|
||||
import io
|
||||
import os
|
||||
from ray.serve.exceptions import RayServeException
|
||||
from collections import UserDict
|
||||
|
||||
import requests
|
||||
import numpy as np
|
||||
import pydantic
|
||||
from werkzeug.datastructures import ImmutableMultiDict
|
||||
|
||||
import ray
|
||||
from ray.serve.constants import HTTP_PROXY_TIMEOUT
|
||||
@@ -24,6 +24,14 @@ from ray.serve.http_util import build_flask_request
|
||||
ACTOR_FAILURE_RETRY_TIMEOUT_S = 60
|
||||
|
||||
|
||||
class ServeMultiDict(UserDict):
|
||||
"""Compatible data structure to simulate Flask.Request.args API."""
|
||||
|
||||
def getlist(self, key):
|
||||
"""Return the list of items for a given key."""
|
||||
return self.data.get(key, [])
|
||||
|
||||
|
||||
class ServeRequest:
|
||||
"""The request object used in Python context.
|
||||
|
||||
@@ -34,7 +42,7 @@ class ServeRequest:
|
||||
|
||||
def __init__(self, data, kwargs, headers, method):
|
||||
self._data = data
|
||||
self._kwargs = kwargs
|
||||
self._kwargs = ServeMultiDict(kwargs)
|
||||
self._headers = headers
|
||||
self._method = method
|
||||
|
||||
@@ -51,7 +59,7 @@ class ServeRequest:
|
||||
@property
|
||||
def args(self):
|
||||
"""The keyword arguments from ``handle.remote(**kwargs)``."""
|
||||
return ImmutableMultiDict(self._kwargs)
|
||||
return self._kwargs
|
||||
|
||||
@property
|
||||
def json(self):
|
||||
|
||||
Reference in New Issue
Block a user