spaces 0.50.dev2__tar.gz → 0.50.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. {spaces-0.50.dev2 → spaces-0.50.1}/PKG-INFO +3 -4
  2. {spaces-0.50.dev2 → spaces-0.50.1}/pyproject.toml +13 -19
  3. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/__init__.py +39 -13
  4. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/config.py +2 -0
  5. spaces-0.50.1/spaces/gradio.py +53 -0
  6. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/reloading/__init__.py +2 -6
  7. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/reloading/server.py +0 -5
  8. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/utils.py +12 -5
  9. spaces-0.50.1/spaces/zero/__init__.py +41 -0
  10. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/client.py +92 -71
  11. spaces-0.50.1/spaces/zero/config.py +52 -0
  12. spaces-0.50.1/spaces/zero/configs.json +20 -0
  13. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/decorator.py +3 -2
  14. spaces-0.50.1/spaces/zero/elf.py +37 -0
  15. spaces-0.50.1/spaces/zero/gradio.py +188 -0
  16. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/torch/aoti.py +132 -8
  17. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/torch/patching.py +4 -1
  18. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/torch/static.py +9 -6
  19. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/types.py +10 -18
  20. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/wrappers.py +88 -62
  21. spaces-0.50.dev2/spaces/_vendor/asgiref/__init__.py +0 -0
  22. spaces-0.50.dev2/spaces/_vendor/asgiref/typing.py +0 -279
  23. spaces-0.50.dev2/spaces/zero/__init__.py +0 -44
  24. spaces-0.50.dev2/spaces/zero/context.py +0 -114
  25. spaces-0.50.dev2/spaces/zero/gradio.py +0 -131
  26. spaces-0.50.dev2/spaces/zero/lifecycle.py +0 -38
  27. spaces-0.50.dev2/spaces/zero/middleware.py +0 -107
  28. {spaces-0.50.dev2 → spaces-0.50.1}/README.md +0 -0
  29. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/__init__.py +0 -0
  30. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/codefind/LICENSE +0 -0
  31. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/codefind/__init__.py +0 -0
  32. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/codefind/registry.py +0 -0
  33. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/codefind/version.py +0 -0
  34. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/jurigged/LICENSE +0 -0
  35. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/jurigged/__init__.py +0 -0
  36. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/jurigged/codetools.py +0 -0
  37. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/jurigged/parse.py +0 -0
  38. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/jurigged/register.py +0 -0
  39. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/jurigged/utils.py +0 -0
  40. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/jurigged/version.py +0 -0
  41. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/LICENSE +0 -0
  42. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/__init__.py +0 -0
  43. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/abc.py +0 -0
  44. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/codegen.py +0 -0
  45. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/core.py +0 -0
  46. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/dependent.py +0 -0
  47. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/medley.py +0 -0
  48. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/mro.py +0 -0
  49. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/py.typed +0 -0
  50. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/recode.py +0 -0
  51. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/signatures.py +0 -0
  52. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/typemap.py +0 -0
  53. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/types.py +0 -0
  54. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/utils.py +0 -0
  55. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/ovld/version.py +0 -0
  56. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/sse_starlette/LICENSE +0 -0
  57. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/sse_starlette/__init__.py +0 -0
  58. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/sse_starlette/event.py +0 -0
  59. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/sse_starlette/py.typed +0 -0
  60. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/sse_starlette/sse.py +0 -0
  61. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/sseclient/LICENSE +0 -0
  62. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/_vendor/sseclient/__init__.py +0 -0
  63. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/reloading/client.py +0 -0
  64. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/reloading/types.py +0 -0
  65. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/reloading/types.ts +0 -0
  66. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/api.py +0 -0
  67. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/mmap.py +0 -0
  68. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/torch/__init__.py +0 -0
  69. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/torch/bitsandbytes.py +0 -0
  70. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/torch/bitsandbytes_legacy.py +0 -0
  71. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/torch/cudart.py +0 -0
  72. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/torch/packing.py +0 -0
  73. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/torch/patching_legacy.py +0 -0
  74. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/torch/types.py +0 -0
  75. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/torch/utils.py +0 -0
  76. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/tqdm.py +0 -0
  77. {spaces-0.50.dev2 → spaces-0.50.1}/spaces/zero/utils.py +0 -0
@@ -1,20 +1,19 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spaces
3
- Version: 0.50.dev2
3
+ Version: 0.50.1
4
4
  Summary: Utilities for Hugging Face Spaces
5
5
  Author: Charles Bensimon
6
6
  Author-email: Charles Bensimon <charles@huggingface.co>
7
7
  License-Expression: Apache-2.0
8
8
  Requires-Dist: packaging
9
9
  Requires-Dist: typing-extensions>=4,<5
10
+ Requires-Dist: requests>=2.19,<3
11
+ Requires-Dist: gradio
10
12
  Requires-Dist: pydantic>=1,<3
11
13
  Requires-Dist: httpx>=0.20
12
- Requires-Dist: fastapi ; extra == 'serving'
13
- Requires-Dist: uvicorn ; extra == 'serving'
14
14
  Requires-Python: >=3.10, <3.15
15
15
  Project-URL: Homepage, https://huggingface.co
16
16
  Project-URL: Repository, https://github.com/huggingface/huggingface_hub
17
- Provides-Extra: serving
18
17
  Description-Content-Type: text/markdown
19
18
 
20
19
  # Hugging Face Spaces
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "spaces"
3
- version = "0.50.dev2"
3
+ version = "0.50.1"
4
4
  description = "Utilities for Hugging Face Spaces"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10,<3.15"
@@ -11,16 +11,12 @@ authors = [
11
11
  dependencies = [
12
12
  "packaging",
13
13
  "typing-extensions>=4,<5",
14
+ "requests>=2.19,<3",
15
+ "gradio", # Actually requires 3.2+ if for `@spaces.GPU`
14
16
  "pydantic>=1,<3",
15
17
  "httpx>=0.20",
16
18
  ]
17
19
 
18
- [project.optional-dependencies]
19
- serving = [
20
- "fastapi",
21
- "uvicorn"
22
- ]
23
-
24
20
  [project.urls]
25
21
  Homepage = "https://huggingface.co"
26
22
  Repository = "https://github.com/huggingface/huggingface_hub"
@@ -30,20 +26,20 @@ dev = [
30
26
  "pytest>=7.3.1,<8",
31
27
  "pytest-dotenv>=0.5.2,<0.6",
32
28
  "pytest-mock>=3.10.0,<4",
29
+ "requests-mock>=1.10.0,<2",
33
30
  "pytest-timeout>=2.1.0,<3",
34
31
  "poethepoet>=0.20.0,<0.21",
35
32
  "coverage>=7.2.6,<8",
36
33
  "pyright>=1.1.403,<2",
37
34
  "pytest-order>=1.1.0,<2",
38
35
  "pynvml>=11.5.0,<12",
36
+ "websockets>=13.0,<14",
39
37
  "pytest-asyncio>=0.21.1,<0.22",
40
38
  "pytest-httpx>=0.27.0,<0.28",
41
39
  "pydantic-to-typescript>=2.0.0,<3",
42
- "requests>=2.19,<3",
43
40
  "setuptools",
44
41
  ]
45
42
  test = [
46
- "gradio",
47
43
  "diffusers",
48
44
  "transformers",
49
45
  "accelerate",
@@ -55,13 +51,6 @@ test = [
55
51
  "kernels>=0.10.2,<0.11",
56
52
  ]
57
53
 
58
- [tool.uv]
59
- constraint-dependencies = [
60
- "numpy<2",
61
- "peft<0.19",
62
- "transformers<4.51",
63
- ]
64
-
65
54
  [tool.pytest.ini_options]
66
55
  addopts = "-v"
67
56
  testpaths = ["tests"]
@@ -71,6 +60,7 @@ env_files = ["tests/.env"]
71
60
  source = ["spaces"]
72
61
  omit = [
73
62
  "spaces/zero/api.py",
63
+ "spaces/zero/torch/aoti.py", # For now
74
64
  "spaces/zero/torch/patching_legacy.py",
75
65
  "spaces/zero/torch/bitsandbytes_legacy.py",
76
66
  "spaces/_vendor/*",
@@ -93,8 +83,6 @@ shell = """set -e
93
83
  coverage run -m pytest tests/cpu
94
84
  coverage run -m pytest tests/gpu
95
85
  find e2e -name '*.py' | xargs -I {} coverage run {}
96
- pytest tests/cpu/serving/test_middleware.py::test_fds_server_hang --fd-xfail
97
- pytest tests/cpu/serving/test_middleware.py::test_fds_requests_hang --fd-xfail
98
86
  coverage combine -q
99
87
  coverage xml || true
100
88
  coverage html || true
@@ -113,11 +101,17 @@ shell = """set -e
113
101
  include = ["spaces", "tests"]
114
102
  exclude = ["spaces/_vendor"]
115
103
  pythonVersion = "3.10"
116
- reportMatchNotExhaustive = "error"
117
104
  reportPossiblyUnboundVariable = "error"
118
105
  reportUnnecessaryComparison = true
119
106
  reportPrivateImportUsage = "information"
120
107
 
108
+ [tool.uv]
109
+ constraint-dependencies = [
110
+ "numpy<2",
111
+ "peft<0.19",
112
+ "transformers<4.51",
113
+ ]
114
+
121
115
  [build-system]
122
116
  requires = ["uv_build>=0.11.6,<0.12"]
123
117
  build-backend = "uv_build"
@@ -1,14 +1,12 @@
1
1
  """
2
2
  """
3
-
4
3
  import sys
5
- import warnings
6
4
  from types import FunctionType
7
5
  from typing import TYPE_CHECKING
8
6
  from typing import Callable
9
7
 
10
8
 
11
- # Prevent partially-imported gradio from importing spaces
9
+ # Prevent gradio from importing spaces
12
10
  if (gr := sys.modules.get('gradio')) is not None: # pragma: no cover
13
11
  try:
14
12
  gr.Blocks
@@ -17,16 +15,9 @@ if (gr := sys.modules.get('gradio')) is not None: # pragma: no cover
17
15
 
18
16
 
19
17
  from .zero.decorator import GPU
20
-
21
-
22
- def gradio_auto_wrap(*args, **kwargs): # pragma: no cover
23
- warnings.warn("gradio_auto_wrap has no effect and is deprecated")
24
-
25
- def disable_gradio_auto_wrap(*args, **kwargs): # pragma: no cover
26
- warnings.warn("gradio_auto_wrap has no effect and is deprecated")
27
-
28
- def enable_gradio_auto_wrap(*args, **kwargs): # pragma: no cover
29
- warnings.warn("gradio_auto_wrap has no effect and is deprecated")
18
+ from .gradio import gradio_auto_wrap
19
+ from .gradio import disable_gradio_auto_wrap
20
+ from .gradio import enable_gradio_auto_wrap
30
21
 
31
22
 
32
23
  class LazyImported:
@@ -59,10 +50,30 @@ def _aoti_compile():
59
50
  from .zero.torch.aoti import aoti_compile
60
51
  return aoti_compile
61
52
 
53
+ def _aoti_compile_and_save(): # pragma: no cover
54
+ from .zero.torch.aoti import aoti_compile_and_save
55
+ return aoti_compile_and_save
56
+
62
57
  def _aoti_apply():
63
58
  from .zero.torch.aoti import aoti_apply
64
59
  return aoti_apply
65
60
 
61
+ def _aoti_patch(): # pragma: no cover
62
+ from .zero.torch.aoti import aoti_patch
63
+ return aoti_patch
64
+
65
+ def _aoti_load(): # pragma: no cover
66
+ from .zero.torch.aoti import aoti_load
67
+ return aoti_load
68
+
69
+ def _aoti_load_call_source(): # pragma: no cover
70
+ from .zero.torch.aoti import aoti_load_call_source
71
+ return aoti_load_call_source
72
+
73
+ def _aoti_load_from_package_dir(): # pragma: no cover
74
+ from .zero.torch.aoti import aoti_load_from_package_dir
75
+ return aoti_load_from_package_dir
76
+
66
77
  def _aoti_blocks_load():
67
78
  from .zero.torch.aoti import aoti_blocks_load
68
79
  return aoti_blocks_load
@@ -70,14 +81,24 @@ def _aoti_blocks_load():
70
81
 
71
82
  aoti_capture = LazyImported(_aoti_capture)
72
83
  aoti_compile = LazyImported(_aoti_compile)
84
+ aoti_compile_and_save = LazyImported(_aoti_compile_and_save)
73
85
  aoti_apply = LazyImported(_aoti_apply)
86
+ aoti_patch = LazyImported(_aoti_patch)
87
+ aoti_load = LazyImported(_aoti_load)
88
+ aoti_load_call_source = LazyImported(_aoti_load_call_source)
89
+ aoti_load_from_package_dir = LazyImported(_aoti_load_from_package_dir)
74
90
  aoti_blocks_load = LazyImported(_aoti_blocks_load)
75
91
 
76
92
 
77
93
  if TYPE_CHECKING:
78
94
  from .zero.torch.aoti import aoti_capture
79
95
  from .zero.torch.aoti import aoti_compile
96
+ from .zero.torch.aoti import aoti_compile_and_save
80
97
  from .zero.torch.aoti import aoti_apply
98
+ from .zero.torch.aoti import aoti_patch
99
+ from .zero.torch.aoti import aoti_load
100
+ from .zero.torch.aoti import aoti_load_call_source
101
+ from .zero.torch.aoti import aoti_load_from_package_dir
81
102
  from .zero.torch.aoti import aoti_blocks_load
82
103
 
83
104
 
@@ -88,6 +109,11 @@ __all__ = [
88
109
  'enable_gradio_auto_wrap',
89
110
  'aoti_capture',
90
111
  'aoti_compile',
112
+ 'aoti_compile_and_save',
91
113
  'aoti_apply',
114
+ 'aoti_patch',
115
+ 'aoti_load',
116
+ 'aoti_load_call_source',
117
+ 'aoti_load_from_package_dir',
92
118
  'aoti_blocks_load',
93
119
  ]
@@ -18,6 +18,8 @@ class Settings:
18
18
  os.getenv('SPACES_ZERO_GPU'))
19
19
  self.zero_device_api_url = (
20
20
  os.getenv('SPACES_ZERO_DEVICE_API_URL'))
21
+ self.gradio_auto_wrap = boolean(
22
+ os.getenv('SPACES_GRADIO_AUTO_WRAP'))
21
23
  self.zero_patch_torch_device = boolean(
22
24
  os.getenv('ZERO_GPU_PATCH_TORCH_DEVICE'))
23
25
  self.zero_gpu_v2 = boolean(
@@ -0,0 +1,53 @@
1
+ """
2
+ """
3
+ from typing import Callable
4
+ from typing import Generator
5
+ from typing import TypeVar
6
+ from typing import overload
7
+ from typing_extensions import ParamSpec
8
+
9
+ from .config import Config
10
+ from .zero.decorator import GPU
11
+
12
+
13
+ Param = ParamSpec('Param')
14
+ Res = TypeVar('Res')
15
+
16
+
17
+ gradio_auto_wrap_enabled = Config.gradio_auto_wrap
18
+
19
+
20
+ def disable_gradio_auto_wrap():
21
+ global gradio_auto_wrap_enabled
22
+ gradio_auto_wrap_enabled = False
23
+
24
+ def enable_gradio_auto_wrap():
25
+ global gradio_auto_wrap_enabled
26
+ gradio_auto_wrap_enabled = True
27
+
28
+
29
+ @overload
30
+ def gradio_auto_wrap(
31
+ task:
32
+ Callable[Param, Res],
33
+ ) -> Callable[Param, Res]:
34
+ ...
35
+ @overload
36
+ def gradio_auto_wrap(
37
+ task:
38
+ None,
39
+ ) -> None:
40
+ ...
41
+ def gradio_auto_wrap(
42
+ task:
43
+ Callable[Param, Res]
44
+ | None,
45
+ ) -> (Callable[Param, Res]
46
+ | None):
47
+ """
48
+ """
49
+ if not gradio_auto_wrap_enabled:
50
+ return task
51
+ if not callable(task):
52
+ return task
53
+ return GPU(task) # type: ignore
@@ -1,10 +1,8 @@
1
1
  """
2
2
  """
3
-
4
3
  import threading
5
4
  from typing import Any
6
5
  from typing import Callable
7
- from uuid import uuid4
8
6
 
9
7
 
10
8
  reload_server_ports: set[int] = set()
@@ -16,7 +14,6 @@ def start_reload_server(
16
14
  stop_event: threading.Event,
17
15
  port: int = 7887,
18
16
  ):
19
- from ..zero.context import GlobalContext
20
17
  from .server import ReloadServer
21
18
 
22
19
  reload_server = ReloadServer(
@@ -25,9 +22,8 @@ def start_reload_server(
25
22
  stop_event=stop_event,
26
23
  )
27
24
 
28
- server_port_uuid = uuid4()
29
- GlobalContext.server_ports[server_port_uuid] = port
25
+ reload_server_ports.add(port)
30
26
  try:
31
27
  reload_server.run(port=port)
32
28
  finally:
33
- del GlobalContext.server_ports[server_port_uuid]
29
+ reload_server_ports.remove(port)
@@ -12,11 +12,6 @@ from typing_extensions import assert_type
12
12
  from typing_extensions import Never
13
13
  from uuid import uuid4
14
14
 
15
- try:
16
- import fastapi, uvicorn
17
- except ModuleNotFoundError: # pragma: no cover
18
- raise RuntimeError("spaces.reloading.server requires FastAPI and uvicorn")
19
-
20
15
  from fastapi import APIRouter
21
16
  from fastapi import FastAPI
22
17
  from fastapi import HTTPException
@@ -30,8 +30,10 @@ class SimpleQueue(_SimpleQueue[T]):
30
30
  raise # pragma: no cover
31
31
  # https://bugs.python.org/issue29187
32
32
  except Exception as e:
33
- # Always assume a PicklingError
34
- raise PicklingError from e
33
+ message = str(e)
34
+ if not "pickle" in message:
35
+ raise # pragma: no cover
36
+ raise PicklingError(message)
35
37
  def wlock_release(self):
36
38
  if (lock := getattr(self, '_wlock', None)) is None:
37
39
  return # pragma: no cover
@@ -47,12 +49,17 @@ def drop_params(fn: Callable[[], T]) -> Callable[..., T]:
47
49
  return drop
48
50
 
49
51
 
52
+ def gradio_request_var():
53
+ try:
54
+ from gradio.context import LocalContext
55
+ except ImportError: # pragma: no cover
56
+ raise RuntimeError(GRADIO_VERSION_ERROR_MESSAGE)
57
+ return LocalContext.request
58
+
59
+
50
60
  debug = partial(print, 'SPACES_ZERO_GPU_DEBUG')
51
61
 
52
62
 
53
63
  # Type-safe threads
54
64
  def create_thread(fn: Callable[P, Any], *args: P.args, **kwargs: P.kwargs) -> Thread:
55
65
  return Thread(target=fn, args=args, kwargs=kwargs)
56
-
57
- def create_thread_daemon(fn: Callable[P, Any], *args: P.args, **kwargs: P.kwargs) -> Thread:
58
- return Thread(target=fn, args=args, kwargs=kwargs, daemon=True)
@@ -0,0 +1,41 @@
1
+ """
2
+ """
3
+
4
+ from ..config import Config
5
+
6
+
7
+ _default_gpu_size: 'api.GPUSize | None' = None
8
+
9
+
10
+ def default_gpu_size():
11
+ return _default_gpu_size
12
+
13
+
14
+ if Config.zero_gpu:
15
+
16
+ from . import api
17
+ from . import client
18
+ from . import config
19
+ from . import decorator
20
+ from . import gradio
21
+ from . import torch
22
+
23
+ if torch.is_in_bad_fork():
24
+ raise RuntimeError(
25
+ "CUDA has been initialized before importing the `spaces` package. "
26
+ "Try importing `spaces` before any other CUDA-related package."
27
+ )
28
+
29
+ def startup():
30
+ global _default_gpu_size
31
+ zerogpu_config = config.get_config()
32
+ total_size = torch.pack()
33
+ threshold = zerogpu_config['xlarge_threshold']
34
+ if threshold is not None and total_size > threshold:
35
+ _default_gpu_size = 'xlarge' # pragma: no cover
36
+ if len(decorator.decorated_cache) == 0:
37
+ return # pragma: no cover
38
+ client.startup_report()
39
+
40
+ torch.patch()
41
+ gradio.one_launch(startup)