Skip to content

Commit

Permalink
fix: support gradio 4.35.0 in mgr.load (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Col0ring authored Jun 13, 2024
1 parent d2e24dc commit a10188e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-stingrays-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'modelscope_studio': patch
---

fix: support gradio 4.35.0 in mgr.load
11 changes: 8 additions & 3 deletions backend/modelscope_studio/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,13 @@ def from_spaces_blocks(
try:
space = f"{_endpoint}/api/v1/studio/{space_name}/gradio/"
kwargs = {}
if version.Version(gradio.__version__) > version.Version('4.19.1'):
kwargs["upload_files"] = False
if version.Version(gradio.__version__) > version.Version('4.35.0'):
kwargs["download_files"] = False
kwargs["_skip_components"] = False
elif version.Version(gradio.__version__) > version.Version('4.19.1'):
kwargs["download_files"] = False
kwargs["_skip_components"] = False
kwargs["upload_files"] = False
elif version.Version(gradio.__version__) == version.Version('4.19.1'):
kwargs["download_files"] = False
client = Client(
Expand All @@ -296,7 +299,9 @@ def from_spaces_blocks(

# Use end_to_end_fn here to properly upload/download all files
predict_fns = []
for fn_index, endpoint in enumerate(client.endpoints):

for fn_index, endpoint in enumerate(client.endpoints) if isinstance(
client.endpoints, list) else client.endpoints.items():
if not isinstance(endpoint, Endpoint):
raise TypeError(
f"Expected endpoint to be an Endpoint, but got {type(endpoint)}"
Expand Down

0 comments on commit a10188e

Please sign in to comment.