Skip to content

Commit

Permalink
fix(client): Convert string to Path if it isn't like a URL (#4469)
Browse files Browse the repository at this point in the history
fix: Convert string to Path if it isn't like a URL

Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming authored Feb 1, 2024
1 parent 189ffc0 commit 0a158ca
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/_bentoml_impl/client/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down Expand Up @@ -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(
(
Expand Down

0 comments on commit 0a158ca

Please sign in to comment.