From 907e1ae570f15eae6577f5c027347963d5e9598e Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Thu, 1 Feb 2024 17:39:47 +0800 Subject: [PATCH] fix: Convert string to Path if it isn't like a URL Signed-off-by: Frost Ming --- src/_bentoml_impl/client/http.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/_bentoml_impl/client/http.py b/src/_bentoml_impl/client/http.py index 678eee03e62..e265b97f028 100644 --- a/src/_bentoml_impl/client/http.py +++ b/src/_bentoml_impl/client/http.py @@ -42,6 +42,10 @@ MAX_RETRIES = 3 +def is_http_url(url: str) -> bool: + return urlparse(url).scheme in {"http", "https"} + + @attr.define class HTTPClient(AbstractClient, t.Generic[C]): client_cls: t.ClassVar[type[BaseClient]] @@ -257,6 +261,8 @@ def is_file_field(k: str) -> bool: value = [value] for v in value: + if isinstance(v, str) and not is_http_url(v): + v = pathlib.Path(v) if is_image_type(type(v)): files.append( (