tensorferry 0.2.0__tar.gz → 0.2.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.
- {tensorferry-0.2.0/src/tensorferry.egg-info → tensorferry-0.2.1}/PKG-INFO +1 -1
- {tensorferry-0.2.0 → tensorferry-0.2.1}/pyproject.toml +1 -1
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/store.py +26 -4
- {tensorferry-0.2.0 → tensorferry-0.2.1/src/tensorferry.egg-info}/PKG-INFO +1 -1
- {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_progress.py +10 -6
- {tensorferry-0.2.0 → tensorferry-0.2.1}/LICENSE +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/MANIFEST.in +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/README.md +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/scripts/bench_remote.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/setup.cfg +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/__init__.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/_pool.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/api.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/backend.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/cache.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/formats.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/jax.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/loader.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/plan.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/progress.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/torch.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry.egg-info/SOURCES.txt +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry.egg-info/dependency_links.txt +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry.egg-info/requires.txt +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry.egg-info/top_level.txt +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/__init__.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/_files.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/conftest.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_cache.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_formats.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_jax.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_loader.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_remote.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_store.py +0 -0
- {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_torch.py +0 -0
|
@@ -178,6 +178,10 @@ class CallbackStore:
|
|
|
178
178
|
return self.size_fn(name)
|
|
179
179
|
|
|
180
180
|
|
|
181
|
+
# Chunk size for obstore streaming reads when download progress is tracked (obstore's default is 10 MiB).
|
|
182
|
+
_PROGRESS_CHUNK_BYTES = 512 << 10
|
|
183
|
+
|
|
184
|
+
|
|
181
185
|
class ObjectStore:
|
|
182
186
|
"""Hub authentication uses the supplied token or the locally configured Hugging Face token."""
|
|
183
187
|
|
|
@@ -211,11 +215,29 @@ class ObjectStore:
|
|
|
211
215
|
if stop <= start:
|
|
212
216
|
return b""
|
|
213
217
|
if self._is_remote and _download.get() is not None:
|
|
214
|
-
|
|
215
|
-
|
|
218
|
+
result = obstore.get(self.store, name, options={"range": (start, stop)})
|
|
219
|
+
stream = result.stream(min_chunk_size=_PROGRESS_CHUNK_BYTES)
|
|
220
|
+
first = next(stream, None)
|
|
221
|
+
if first is None:
|
|
222
|
+
return b""
|
|
223
|
+
_record_read(first)
|
|
224
|
+
span = getattr(result, "range", None)
|
|
225
|
+
expected = stop - start if span is None else span[1] - span[0]
|
|
226
|
+
if len(first) >= expected:
|
|
227
|
+
return first
|
|
228
|
+
out = np.empty(expected, np.uint8)
|
|
229
|
+
at = len(first)
|
|
230
|
+
out[:at] = np.frombuffer(first, np.uint8)
|
|
231
|
+
for chunk in stream:
|
|
216
232
|
_record_read(chunk)
|
|
217
|
-
|
|
218
|
-
|
|
233
|
+
n = len(chunk)
|
|
234
|
+
if at + n > out.size:
|
|
235
|
+
grown = np.empty(at + n, np.uint8)
|
|
236
|
+
grown[:at] = out[:at]
|
|
237
|
+
out = grown
|
|
238
|
+
out[at : at + n] = np.frombuffer(chunk, np.uint8)
|
|
239
|
+
at += n
|
|
240
|
+
return out[:at]
|
|
219
241
|
data = obstore.get_range(self.store, name, start=start, end=stop)
|
|
220
242
|
if self._is_remote:
|
|
221
243
|
_record_read(data)
|
|
@@ -155,6 +155,7 @@ def test_download_progress_streams_chunks_and_untracked_uses_get_range(monkeypat
|
|
|
155
155
|
chunk1_recorded, release_chunk2 = threading.Event(), threading.Event()
|
|
156
156
|
split = weights.nbytes // 2
|
|
157
157
|
prefetched = []
|
|
158
|
+
stream_chunk_sizes: list[int] = []
|
|
158
159
|
|
|
159
160
|
def stream_get(backend, name, *, options):
|
|
160
161
|
result = get(backend, name, options=options)
|
|
@@ -162,13 +163,15 @@ def test_download_progress_streams_chunks_and_untracked_uses_get_range(monkeypat
|
|
|
162
163
|
if isinstance(byte_range, tuple) and byte_range[0] > 0:
|
|
163
164
|
data = bytes(result.bytes())
|
|
164
165
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
class _FakeResult:
|
|
167
|
+
def stream(self, min_chunk_size: int = 10 << 20):
|
|
168
|
+
stream_chunk_sizes.append(min_chunk_size)
|
|
169
|
+
yield data[:split]
|
|
170
|
+
chunk1_recorded.set()
|
|
171
|
+
assert release_chunk2.wait(10)
|
|
172
|
+
yield data[split:]
|
|
170
173
|
|
|
171
|
-
return
|
|
174
|
+
return _FakeResult()
|
|
172
175
|
start, stop = result.range
|
|
173
176
|
prefetched.append(stop - start)
|
|
174
177
|
return result
|
|
@@ -183,6 +186,7 @@ def test_download_progress_streams_chunks_and_untracked_uses_get_range(monkeypat
|
|
|
183
186
|
release_chunk2.set()
|
|
184
187
|
np.testing.assert_array_equal(pending.result(timeout=10)["weights"], weights)
|
|
185
188
|
assert progress.snapshot() == (before + weights.nbytes, before + weights.nbytes)
|
|
189
|
+
assert stream_chunk_sizes == [512 << 10]
|
|
186
190
|
finally:
|
|
187
191
|
release_chunk2.set()
|
|
188
192
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|