Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradio 4.25.0 #1510

Merged
merged 7 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions gradio_utils/grclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import concurrent
import difflib
import threading
import traceback
import os
import time
Expand All @@ -12,7 +13,7 @@
from datetime import timedelta
from enum import Enum
from pathlib import Path
from typing import Callable, Generator, Any, Union, List, Dict, Optional
from typing import Callable, Generator, Any, Union, List, Dict, Optional, Literal
import ast
import inspect
import numpy as np
Expand Down Expand Up @@ -110,13 +111,18 @@ def __init__(
src: str,
hf_token: str | None = None,
max_workers: int = 40,
serialize: bool | None = None,
output_dir: str | Path | None = DEFAULT_TEMP_DIR,
serialize: bool | None = None, # TODO: remove in 1.0
output_dir: str
| Path = DEFAULT_TEMP_DIR, # Maybe this can be combined with `download_files` in 1.0
verbose: bool = False,
auth: tuple[str, str] | None = None,
*,
headers: dict[str, str] | None = None,
upload_files: bool = True,
download_files: bool = True,
upload_files: bool = True, # TODO: remove and hardcode to False in 1.0
download_files: bool = True, # TODO: consider setting to False in 1.0
_skip_components: bool = True, # internal parameter to skip values certain components (e.g. State) that do not need to be displayed to users.
ssl_verify: bool = True,

h2ogpt_key: str = None,
persist: bool = False,
check_hash: bool = True,
Expand Down Expand Up @@ -153,7 +159,11 @@ def __init__(
# 4.18.0:
# self.kwargs.update(dict(auth=auth, upload_files=upload_files, download_files=download_files))
# 4.17.0:
self.kwargs.update(dict(auth=auth))
# self.kwargs.update(dict(auth=auth))
# 4.24.0:
self._skip_components = _skip_components
self.ssl_verify = ssl_verify
self.kwargs.update(dict(auth=auth, upload_files=upload_files, download_files=download_files, ssl_verify=ssl_verify))

self.verbose = verbose
self.hf_token = hf_token
Expand Down Expand Up @@ -245,10 +255,13 @@ def setup(self):
self.config = self._get_config()
self.api_url = urllib.parse.urljoin(self.src, utils.API_URL)
if is_gradio_client_version7plus:
self.protocol: str = self.config.get("protocol", "ws")
self.protocol: Literal[
"ws", "sse", "sse_v1", "sse_v2", "sse_v2.1"
] = self.config.get("protocol", "ws")
self.sse_url = urllib.parse.urljoin(
self.src, utils.SSE_URL_V0 if self.protocol == "sse" else utils.SSE_URL
)
self.heartbeat_url = urllib.parse.urljoin(self.src, utils.HEARTBEAT_URL)
self.sse_data_url = urllib.parse.urljoin(
self.src,
utils.SSE_DATA_URL_V0 if self.protocol == "sse" else utils.SSE_DATA_URL,
Expand All @@ -260,13 +273,18 @@ def setup(self):
self.reset_url = urllib.parse.urljoin(self.src, utils.RESET_URL)
if is_gradio_client_version7plus:
self.app_version = version.parse(self.config.get("version", "2.0"))
self._info = None
self._info = self._get_api_info()
self.session_hash = str(uuid.uuid4())

self.get_endpoints(self)

# Disable telemetry by setting the env variable HF_HUB_DISABLE_TELEMETRY=1
# threading.Thread(target=self._telemetry_thread).start()
# threading.Thread(target=self._telemetry_thread, daemon=True).start()
self._refresh_heartbeat = threading.Event()
self._kill_heartbeat = threading.Event()

self.heartbeat = threading.Thread(target=self._stream_heartbeat, daemon=True)
self.heartbeat.start()

self.server_hash = self.get_server_hash()

Expand Down
4 changes: 2 additions & 2 deletions reqs_optional/reqs_constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ensure doesn't drift, e.g. Issue #1348
torch==2.2.1
gradio==4.20.1
gradio_client==0.11.0
gradio==4.25.0
gradio_client==0.15.0
transformers==4.39.2
9 changes: 2 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
datasets==2.16.1
sentencepiece==0.2.0
# no websockets, more cloud friendly
#gradio==4.19.2
# able to make gradio clean-up states
gradio @ https://h2o-release.s3.amazonaws.com/h2ogpt/gradio-4.20.1-py3-none-any.whl
#gradio==3.50.2
gradio @ https://h2o-release.s3.amazonaws.com/h2ogpt/gradio-4.25.0-py3-none-any.whl
gradio_client @ https://h2o-release.s3.amazonaws.com/h2ogpt/gradio_client-0.15.0-py3-none-any.whl
sse_starlette==1.8.2
# consrained by tokenizers etc.:
huggingface_hub>=0.12.4
Expand Down Expand Up @@ -38,10 +37,6 @@ pynvml>=11.5.0
psutil>=5.9.5
boto3>=1.26.101
botocore>=1.29.101

# for gradio client
gradio_client==0.11.0
#gradio_client==0.6.1
beautifulsoup4>=4.12.2
markdown>=3.4.3

Expand Down
Loading