tostorchconnector 1.0.2__tar.gz → 1.0.3__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.

Potentially problematic release.


This version of tostorchconnector might be problematic. Click here for more details.

Files changed (21) hide show
  1. {tostorchconnector-1.0.2/tostorchconnector.egg-info → tostorchconnector-1.0.3}/PKG-INFO +1 -1
  2. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/pyproject.toml +1 -1
  3. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector/tos_object_reader.py +21 -3
  4. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3/tostorchconnector.egg-info}/PKG-INFO +1 -1
  5. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/LICENSE +0 -0
  6. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/README.md +0 -0
  7. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/setup.cfg +0 -0
  8. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tests/test_tos_dataset.py +0 -0
  9. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tests/test_tosnativeclient.py +0 -0
  10. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector/__init__.py +0 -0
  11. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector/tos_checkpoint.py +0 -0
  12. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector/tos_client.py +0 -0
  13. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector/tos_common.py +0 -0
  14. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector/tos_iterable_dataset.py +0 -0
  15. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector/tos_map_dataset.py +0 -0
  16. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector/tos_object_meta.py +0 -0
  17. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector/tos_object_writer.py +0 -0
  18. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector.egg-info/SOURCES.txt +0 -0
  19. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector.egg-info/dependency_links.txt +0 -0
  20. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector.egg-info/requires.txt +0 -0
  21. {tostorchconnector-1.0.2 → tostorchconnector-1.0.3}/tostorchconnector.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tostorchconnector
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: TOS connector integration for PyTorch
5
5
  Author-email: xiangshijian <xiangshijian@bytedance.com>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "tostorchconnector"
8
- version = "1.0.2"
8
+ version = "1.0.3"
9
9
  description = "TOS connector integration for PyTorch"
10
10
  authors = [{ name = "xiangshijian", email = "xiangshijian@bytedance.com" }]
11
11
  requires-python = ">=3.8,<3.13"
@@ -37,6 +37,19 @@ class TosObjectReader(io.BufferedIOBase):
37
37
  def key(self) -> str:
38
38
  return self._key
39
39
 
40
+ def __enter__(self):
41
+ return self
42
+
43
+ def __exit__(self, exc_type, exc_val, exc_tb):
44
+ if exc_type is not None:
45
+ try:
46
+ log.info(f'Exception occurred before closing stream: {exc_type.__name__}: {exc_val}')
47
+ except:
48
+ pass
49
+ else:
50
+ if self._object_stream is not None:
51
+ self._object_stream.close()
52
+
40
53
  def read(self, size: Optional[int] = None) -> Optional[bytes]:
41
54
  if self._is_read_to_end():
42
55
  return b''
@@ -52,11 +65,14 @@ class TosObjectReader(io.BufferedIOBase):
52
65
  while 1:
53
66
  chunk = self._object_stream.read(self._object_stream_offset, chunk_size)
54
67
  if not chunk:
68
+ self._object_stream.close()
55
69
  break
56
70
  self._object_stream_offset += len(chunk)
57
71
  self._buffer.write(chunk)
58
- finally:
72
+ except:
59
73
  self._object_stream.close()
74
+ raise
75
+
60
76
  elif isinstance(self._object_stream, GetObjectOutput):
61
77
  for chunk in self._object_stream:
62
78
  self._buffer.write(chunk)
@@ -149,13 +165,15 @@ class TosObjectReader(io.BufferedIOBase):
149
165
  while offset > size:
150
166
  chunk = self._object_stream.read(self._object_stream_offset, chunk_size)
151
167
  if not chunk:
168
+ self._object_stream.close()
152
169
  break
153
170
  size += self._buffer.write(chunk)
154
171
  self._object_stream_offset += len(chunk)
155
172
  self._total_size = self._buffer.tell()
156
- finally:
173
+ except:
157
174
  self._object_stream.close()
158
- else:
175
+ raise
176
+ elif isinstance(self._object_stream, GetObjectOutput):
159
177
  try:
160
178
  while offset > size:
161
179
  size += self._buffer.write(next(self._object_stream))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tostorchconnector
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: TOS connector integration for PyTorch
5
5
  Author-email: xiangshijian <xiangshijian@bytedance.com>
6
6
  Classifier: Development Status :: 4 - Beta