speedy-utils 1.1.30__tar.gz → 1.1.32__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 (86) hide show
  1. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/PKG-INFO +2 -1
  2. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/pyproject.toml +2 -1
  3. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/__imports.py +115 -30
  4. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/__init__.py +2 -0
  5. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/vision_utils/io_utils.py +159 -123
  6. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/vision_utils/plot.py +2 -2
  7. speedy_utils-1.1.32/tests/import_all.py +1 -0
  8. speedy_utils-1.1.32/tests/import_time_report.py +272 -0
  9. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/uv.lock +15 -1
  10. speedy_utils-1.1.30/scripts/lazy_import.py +0 -11
  11. speedy_utils-1.1.30/src/speedy_utils/all.py +0 -129
  12. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/.github/copilot-instructions.md +0 -0
  13. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/.github/workflows/publish.yml +0 -0
  14. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/.gitignore +0 -0
  15. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/.pre-commit-config.yaml +0 -0
  16. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/README.md +0 -0
  17. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/bumpversion.sh +0 -0
  18. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/examples/temperature_range_example.py +0 -0
  19. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/examples/vision_utils_example.py +0 -0
  20. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/notebooks/llm_utils/llm_as_a_judge.ipynb +0 -0
  21. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/notebooks/test_multi_thread.ipynb +0 -0
  22. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/ruff.toml +0 -0
  23. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/scripts/debug_import_time.py +0 -0
  24. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/scripts/deploy.sh +0 -0
  25. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/scripts/imports.sh +0 -0
  26. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/scripts/test_import_time_vision.py +0 -0
  27. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/setup.cfg +0 -0
  28. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/__init__.py +0 -0
  29. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/chat_format/__init__.py +0 -0
  30. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/chat_format/display.py +0 -0
  31. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/chat_format/transform.py +0 -0
  32. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/chat_format/utils.py +0 -0
  33. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/group_messages.py +0 -0
  34. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/__init__.py +0 -0
  35. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/async_lm/__init__.py +0 -0
  36. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/async_lm/_utils.py +0 -0
  37. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/async_lm/async_llm_task.py +0 -0
  38. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/async_lm/async_lm.py +0 -0
  39. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/async_lm/async_lm_base.py +0 -0
  40. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/async_lm/lm_specific.py +0 -0
  41. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/base_prompt_builder.py +0 -0
  42. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/llm.py +0 -0
  43. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/llm_signature.py +0 -0
  44. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/lm_base.py +0 -0
  45. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/mixins.py +0 -0
  46. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/openai_memoize.py +0 -0
  47. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/signature.py +0 -0
  48. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/lm/utils.py +0 -0
  49. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/scripts/README.md +0 -0
  50. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/scripts/vllm_load_balancer.py +0 -0
  51. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/scripts/vllm_serve.py +0 -0
  52. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/vector_cache/__init__.py +0 -0
  53. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/vector_cache/cli.py +0 -0
  54. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/vector_cache/core.py +0 -0
  55. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/vector_cache/types.py +0 -0
  56. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/llm_utils/vector_cache/utils.py +0 -0
  57. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/common/__init__.py +0 -0
  58. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/common/clock.py +0 -0
  59. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/common/function_decorator.py +0 -0
  60. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/common/logger.py +0 -0
  61. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/common/notebook_utils.py +0 -0
  62. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/common/patcher.py +0 -0
  63. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/common/report_manager.py +0 -0
  64. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/common/utils_cache.py +0 -0
  65. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/common/utils_io.py +0 -0
  66. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/common/utils_misc.py +0 -0
  67. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/common/utils_print.py +0 -0
  68. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/multi_worker/__init__.py +0 -0
  69. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/multi_worker/process.py +0 -0
  70. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/multi_worker/thread.py +0 -0
  71. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/scripts/__init__.py +0 -0
  72. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/scripts/mpython.py +0 -0
  73. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/speedy_utils/scripts/openapi_client_codegen.py +0 -0
  74. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/vision_utils/README.md +0 -0
  75. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/src/vision_utils/__init__.py +0 -0
  76. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/tests/llm_utils/test_llm_mixins.py +0 -0
  77. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/tests/sample_objects.py +0 -0
  78. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/tests/test.py +0 -0
  79. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/tests/test_logger.py +0 -0
  80. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/tests/test_logger_format.py +0 -0
  81. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/tests/test_memoize_typing.py +0 -0
  82. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/tests/test_mpython.py +0 -0
  83. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/tests/test_multithread_error_trace.py +0 -0
  84. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/tests/test_process.py +0 -0
  85. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/tests/test_process_update.py +0 -0
  86. {speedy_utils-1.1.30 → speedy_utils-1.1.32}/tests/test_thread.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: speedy-utils
3
- Version: 1.1.30
3
+ Version: 1.1.32
4
4
  Summary: Fast and easy-to-use package for data science
5
5
  Project-URL: Homepage, https://github.com/anhvth/speedy
6
6
  Project-URL: Repository, https://github.com/anhvth/speedy
@@ -39,6 +39,7 @@ Requires-Dist: pydantic
39
39
  Requires-Dist: pytest
40
40
  Requires-Dist: ray
41
41
  Requires-Dist: requests
42
+ Requires-Dist: ruff
42
43
  Requires-Dist: scikit-learn
43
44
  Requires-Dist: tabulate
44
45
  Requires-Dist: tqdm
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "speedy-utils"
3
- version = "1.1.30"
3
+ version = "1.1.32"
4
4
  description = "Fast and easy-to-use package for data science"
5
5
  authors = [{ name = "AnhVTH", email = "anhvth.226@gmail.com" }]
6
6
  readme = "README.md"
@@ -23,6 +23,7 @@ dependencies = [
23
23
  "pydantic",
24
24
  "tqdm",
25
25
  "cachetools",
26
+ "ruff",
26
27
  "bump2version",
27
28
  "json-repair",
28
29
  "fastprogress",
@@ -5,15 +5,6 @@ import time
5
5
  import warnings
6
6
 
7
7
 
8
- # Suppress lazy_loader subpackage warning
9
- warnings.filterwarnings(
10
- 'ignore',
11
- message='subpackages can technically be lazily loaded',
12
- category=RuntimeWarning,
13
- module='lazy_loader',
14
- )
15
-
16
- t = time.time()
17
8
  # Third-party imports
18
9
  try:
19
10
  # Python 3.10+
@@ -86,7 +77,6 @@ from typing import (
86
77
  )
87
78
 
88
79
  import cachetools
89
- import lazy_loader as lazy
90
80
  import psutil
91
81
  from fastcore.parallel import parallel
92
82
  from json_repair import loads as jloads
@@ -94,27 +84,121 @@ from loguru import logger
94
84
  from tqdm import tqdm
95
85
 
96
86
 
97
- # Resolve long-import-time dependencies lazily
87
+ # Direct imports (previously lazy-loaded)
88
+ import numpy as np
89
+ tabulate = __import__('tabulate').tabulate
90
+ import xxhash
91
+
92
+ # Optional imports - lazy loaded for performance
93
+ def _get_pandas():
94
+ """Lazy import pandas."""
95
+ try:
96
+ import pandas as pd
97
+ return pd
98
+ except ImportError:
99
+ return None
100
+
101
+ def _get_ray():
102
+ """Lazy import ray."""
103
+ try:
104
+ import ray
105
+ return ray
106
+ except ImportError:
107
+ return None
108
+
109
+ def _get_matplotlib():
110
+ """Lazy import matplotlib."""
111
+ try:
112
+ import matplotlib
113
+ return matplotlib
114
+ except ImportError:
115
+ return None
116
+
117
+ def _get_matplotlib_pyplot():
118
+ """Lazy import matplotlib.pyplot."""
119
+ try:
120
+ import matplotlib.pyplot as plt
121
+ return plt
122
+ except ImportError:
123
+ return None
124
+
125
+ def _get_ipython_core():
126
+ """Lazy import IPython.core.getipython."""
127
+ try:
128
+ from IPython.core.getipython import get_ipython
129
+ return get_ipython
130
+ except ImportError:
131
+ return None
132
+
133
+ # Cache for lazy imports
134
+ _pandas_cache = None
135
+ _ray_cache = None
136
+ _matplotlib_cache = None
137
+ _plt_cache = None
138
+ _get_ipython_cache = None
139
+
140
+ # Lazy import classes for performance-critical modules
141
+ class _LazyModule:
142
+ """Lazy module loader that imports only when accessed."""
143
+ def __init__(self, import_func, cache_var_name):
144
+ self._import_func = import_func
145
+ self._cache_var_name = cache_var_name
146
+ self._module = None
147
+
148
+ def __call__(self):
149
+ """Allow calling as a function to get the module."""
150
+ if self._module is None:
151
+ # Use global cache
152
+ cache = globals().get(self._cache_var_name)
153
+ if cache is None:
154
+ cache = self._import_func()
155
+ globals()[self._cache_var_name] = cache
156
+ self._module = cache
157
+ return self._module
158
+
159
+ def __getattr__(self, name):
160
+ """Lazy attribute access."""
161
+ if self._module is None:
162
+ self() # Load the module
163
+ return getattr(self._module, name)
98
164
 
99
- torch = lazy.load('torch') # lazy at runtime
100
- np = lazy.load('numpy')
101
- pd = lazy.load('pandas')
102
- tqdm = lazy.load('tqdm').tqdm # type: ignore # noqa: F811
103
- pd = lazy.load('pandas')
104
- tabulate = lazy.load('tabulate').tabulate
105
- xxhash = lazy.load('xxhash')
106
- get_ipython = lazy.load('IPython.core.getipython')
107
- HTML = lazy.load('IPython.display').HTML
108
- display = lazy.load('IPython.display').display
109
- # logger = lazy.load('loguru').logger
110
- BaseModel = lazy.load('pydantic').BaseModel
111
- _pil = lazy.load('PIL.Image')
112
- Image = _pil.Image
113
- matplotlib = lazy.load('matplotlib')
114
- plt = lazy.load('matplotlib.pyplot')
165
+ def __bool__(self):
166
+ """Support truthiness checks."""
167
+ return self._module is not None
115
168
 
169
+ def __repr__(self):
170
+ if self._module is None:
171
+ return f"<LazyModule: not loaded>"
172
+ return repr(self._module)
116
173
 
117
- ray = lazy.load('ray') # lazy at runtime
174
+ # Create lazy loaders for top slow imports (import only when accessed)
175
+ pd = _LazyModule(_get_pandas, '_pandas_cache')
176
+ ray = _LazyModule(_get_ray, '_ray_cache')
177
+ matplotlib = _LazyModule(_get_matplotlib, '_matplotlib_cache')
178
+ plt = _LazyModule(_get_matplotlib_pyplot, '_plt_cache')
179
+ get_ipython = _LazyModule(_get_ipython_core, '_get_ipython_cache')
180
+
181
+ # Other optional imports (not lazy loaded as they're not in top slow imports)
182
+ try:
183
+ import torch
184
+ except ImportError:
185
+ torch = None
186
+
187
+ try:
188
+ from IPython.display import HTML, display
189
+ except ImportError:
190
+ HTML = None
191
+ display = None
192
+
193
+ try:
194
+ from PIL import Image
195
+ except ImportError:
196
+ Image = None
197
+
198
+ try:
199
+ from pydantic import BaseModel
200
+ except ImportError:
201
+ BaseModel = None
118
202
  if TYPE_CHECKING:
119
203
  import numpy as np
120
204
  import pandas as pd
@@ -133,7 +217,7 @@ if TYPE_CHECKING:
133
217
 
134
218
  __all__ = [
135
219
  # ------------------------------------------------------------------
136
- # Lazy-loaded external modules / objects
220
+ # Direct imports (previously lazy-loaded)
137
221
  # ------------------------------------------------------------------
138
222
  'torch',
139
223
  'np',
@@ -147,6 +231,8 @@ __all__ = [
147
231
  'BaseModel',
148
232
  'Image',
149
233
  'ray',
234
+ 'matplotlib',
235
+ 'plt',
150
236
  # ------------------------------------------------------------------
151
237
  # Standard library modules imported
152
238
  # ------------------------------------------------------------------
@@ -235,7 +321,6 @@ __all__ = [
235
321
  # Third-party modules
236
322
  # ------------------------------------------------------------------
237
323
  'cachetools',
238
- 'lazy',
239
324
  'psutil',
240
325
  'parallel',
241
326
  'jloads',
@@ -113,6 +113,8 @@ __all__ = [
113
113
  'tabulate',
114
114
  'tqdm',
115
115
  'np',
116
+ 'matplotlib',
117
+ 'plt',
116
118
  # Clock module
117
119
  'Clock',
118
120
  'speedy_timer',