pyglove 0.4.5.dev202503260809__py3-none-any.whl → 0.4.5.dev202503280810__py3-none-any.whl
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.
- pyglove/core/io/sequence.py +7 -0
- pyglove/core/io/sequence_test.py +4 -0
- {pyglove-0.4.5.dev202503260809.dist-info → pyglove-0.4.5.dev202503280810.dist-info}/METADATA +1 -1
- {pyglove-0.4.5.dev202503260809.dist-info → pyglove-0.4.5.dev202503280810.dist-info}/RECORD +7 -7
- {pyglove-0.4.5.dev202503260809.dist-info → pyglove-0.4.5.dev202503280810.dist-info}/WHEEL +0 -0
- {pyglove-0.4.5.dev202503260809.dist-info → pyglove-0.4.5.dev202503280810.dist-info}/licenses/LICENSE +0 -0
- {pyglove-0.4.5.dev202503260809.dist-info → pyglove-0.4.5.dev202503280810.dist-info}/top_level.txt +0 -0
pyglove/core/io/sequence.py
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
import abc
|
17
17
|
import collections
|
18
18
|
import os
|
19
|
+
import re
|
19
20
|
from typing import Any, Callable, Iterator, Optional, Union
|
20
21
|
|
21
22
|
from pyglove.core.io import file_system
|
@@ -98,6 +99,9 @@ class SequenceIO(metaclass=abc.ABCMeta):
|
|
98
99
|
"""Opens a sequence for reading or writing."""
|
99
100
|
|
100
101
|
|
102
|
+
_SHARDED_FILE_EXT = re.compile(r'(.*)-(\d+)-of-(\d+)$')
|
103
|
+
|
104
|
+
|
101
105
|
class _SequenceIORegistry(object):
|
102
106
|
"""Registry for record IO systems."""
|
103
107
|
|
@@ -116,6 +120,9 @@ class _SequenceIORegistry(object):
|
|
116
120
|
extension = parts[-1].lower()
|
117
121
|
if '@' in extension:
|
118
122
|
extension = extension.split('@')[0]
|
123
|
+
match = _SHARDED_FILE_EXT.match(extension)
|
124
|
+
if match:
|
125
|
+
extension = match.group(1)
|
119
126
|
if extension in self._registry:
|
120
127
|
return self._registry[extension]
|
121
128
|
return LineSequenceIO()
|
pyglove/core/io/sequence_test.py
CHANGED
@@ -119,6 +119,10 @@ class MemorySequenceIOTest(unittest.TestCase):
|
|
119
119
|
with sequence_io.open_sequence('/file1.mem@123', 'r') as f:
|
120
120
|
self.assertEqual(list(iter(f)), ['abc'])
|
121
121
|
|
122
|
+
def test_sharded_file_name(self):
|
123
|
+
with sequence_io.open_sequence('/file1.mem-00000-of-00001', 'w') as f:
|
124
|
+
self.assertIsInstance(f, sequence_io.MemorySequence)
|
125
|
+
|
122
126
|
|
123
127
|
if __name__ == '__main__':
|
124
128
|
unittest.main()
|
@@ -56,8 +56,8 @@ pyglove/core/hyper/object_template_test.py,sha256=TEFX7LIqUvdCdJILnK_gP5xIgNJKzR
|
|
56
56
|
pyglove/core/io/__init__.py,sha256=4ZT1a595DqQuLTNYc2JP_eCp_KesXvHmKRkr777bzpg,785
|
57
57
|
pyglove/core/io/file_system.py,sha256=E_kSi1Lqo31al4GJYywCzJT97X3ByW8Te4xVfAM93D4,13990
|
58
58
|
pyglove/core/io/file_system_test.py,sha256=quJ74i7uEw7aaNIW6steIvn5VKrei5qOLJuOa4Og64w,8692
|
59
|
-
pyglove/core/io/sequence.py,sha256=
|
60
|
-
pyglove/core/io/sequence_test.py,sha256=
|
59
|
+
pyglove/core/io/sequence.py,sha256=XdVpPBuvhUnrTIWMUrak_qdcNdUJBpjgH5c1b5I3E2A,8873
|
60
|
+
pyglove/core/io/sequence_test.py,sha256=mnONyNG1M1sCae2tyI-tF8qns96htfZPKycthETPthU,4062
|
61
61
|
pyglove/core/patching/__init__.py,sha256=C1Q1cWPV74YL3eXbzGvc-8aPw1DR8EK6lRhQYDCwHek,2059
|
62
62
|
pyglove/core/patching/object_factory.py,sha256=fsiqFET9LWQV4xZXJrPFu3j5IRovSi_zrJba7KiYGZ0,3368
|
63
63
|
pyglove/core/patching/object_factory_test.py,sha256=UXWVxrlgtsKm9Q-CnzJMcKKeFvFi9qQ1GG4RgWt0S8o,3973
|
@@ -212,8 +212,8 @@ pyglove/ext/scalars/randoms.py,sha256=LkMIIx7lOq_lvJvVS3BrgWGuWl7Pi91-lA-O8x_gZs
|
|
212
212
|
pyglove/ext/scalars/randoms_test.py,sha256=nEhiqarg8l_5EOucp59CYrpO2uKxS1pe0hmBdZUzRNM,2000
|
213
213
|
pyglove/ext/scalars/step_wise.py,sha256=IDw3tuTpv0KVh7AN44W43zqm1-E0HWPUlytWOQC9w3Y,3789
|
214
214
|
pyglove/ext/scalars/step_wise_test.py,sha256=TL1vJ19xVx2t5HKuyIzGoogF7N3Rm8YhLE6JF7i0iy8,2540
|
215
|
-
pyglove-0.4.5.
|
216
|
-
pyglove-0.4.5.
|
217
|
-
pyglove-0.4.5.
|
218
|
-
pyglove-0.4.5.
|
219
|
-
pyglove-0.4.5.
|
215
|
+
pyglove-0.4.5.dev202503280810.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
216
|
+
pyglove-0.4.5.dev202503280810.dist-info/METADATA,sha256=IZGK2Igab2QVfh5F2tBYg_fIiRehd7Dqonb5uhvCkLQ,7089
|
217
|
+
pyglove-0.4.5.dev202503280810.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
218
|
+
pyglove-0.4.5.dev202503280810.dist-info/top_level.txt,sha256=wITzJSKcj8GZUkbq-MvUQnFadkiuAv_qv5qQMw0fIow,8
|
219
|
+
pyglove-0.4.5.dev202503280810.dist-info/RECORD,,
|
File without changes
|
{pyglove-0.4.5.dev202503260809.dist-info → pyglove-0.4.5.dev202503280810.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
{pyglove-0.4.5.dev202503260809.dist-info → pyglove-0.4.5.dev202503280810.dist-info}/top_level.txt
RENAMED
File without changes
|