[Serve] Fix handle args data type issue (#10629)

This commit is contained in:
Simon Mo 2020-09-08 12:32:42 -07:00 committed by GitHub
parent 5851e893ee
commit 8d5b8b2956
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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):