returnn 1.20251010.112052__py3-none-any.whl → 1.20251013.3246__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.
Potentially problematic release.
This version of returnn might be problematic. Click here for more details.
- returnn/PKG-INFO +1 -1
- returnn/_setup_info_generated.py +2 -2
- returnn/util/file_cache.py +27 -3
- {returnn-1.20251010.112052.dist-info → returnn-1.20251013.3246.dist-info}/METADATA +1 -1
- {returnn-1.20251010.112052.dist-info → returnn-1.20251013.3246.dist-info}/RECORD +8 -8
- {returnn-1.20251010.112052.dist-info → returnn-1.20251013.3246.dist-info}/LICENSE +0 -0
- {returnn-1.20251010.112052.dist-info → returnn-1.20251013.3246.dist-info}/WHEEL +0 -0
- {returnn-1.20251010.112052.dist-info → returnn-1.20251013.3246.dist-info}/top_level.txt +0 -0
returnn/PKG-INFO
CHANGED
returnn/_setup_info_generated.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
version = '1.
|
|
2
|
-
long_version = '1.
|
|
1
|
+
version = '1.20251013.003246'
|
|
2
|
+
long_version = '1.20251013.003246+git.2e46689'
|
returnn/util/file_cache.py
CHANGED
|
@@ -9,6 +9,7 @@ See https://github.com/rwth-i6/returnn/issues/1519 for initial discussion.
|
|
|
9
9
|
Main class is :class:`FileCache`.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
+
from __future__ import annotations
|
|
12
13
|
from typing import Any, Collection, Dict, Iterable, List, Optional, Tuple, Union
|
|
13
14
|
import errno
|
|
14
15
|
import os
|
|
@@ -143,12 +144,12 @@ class FileCache:
|
|
|
143
144
|
filenames = [filenames]
|
|
144
145
|
self._touch_files_thread.files_remove(fn_ for fn in filenames for fn_ in [fn, self._get_info_filename(fn)])
|
|
145
146
|
|
|
146
|
-
def cleanup(self, *, need_at_least_free_space_size: int = 0):
|
|
147
|
+
def cleanup(self, *, need_at_least_free_space_size: int = 0) -> CleanupResult:
|
|
147
148
|
"""
|
|
148
149
|
Cleanup cache directory.
|
|
149
150
|
"""
|
|
150
151
|
if not os.path.exists(self.cache_directory):
|
|
151
|
-
return
|
|
152
|
+
return CleanupResult(abort_reason="cache directory does not exist")
|
|
152
153
|
disk_usage = shutil.disk_usage(self.cache_directory)
|
|
153
154
|
want_free_space_size = max(
|
|
154
155
|
int(self._cleanup_disk_usage_wanted_multiplier * need_at_least_free_space_size),
|
|
@@ -164,7 +165,13 @@ class FileCache:
|
|
|
164
165
|
cur_time = time.time()
|
|
165
166
|
# If we have enough free space, and we did a full cleanup recently, we don't need to do anything.
|
|
166
167
|
if want_free_space_size <= disk_usage.free and cur_time - last_full_cleanup < 60 * 10:
|
|
167
|
-
return
|
|
168
|
+
return CleanupResult(
|
|
169
|
+
abort_reason=(
|
|
170
|
+
f"enough free space"
|
|
171
|
+
f" ({human_bytes_size(want_free_space_size)} < {human_bytes_size(disk_usage.free)})"
|
|
172
|
+
f" and recent cleanup ({(cur_time - last_full_cleanup) / 60:.1f} minutes ago)"
|
|
173
|
+
)
|
|
174
|
+
)
|
|
168
175
|
# immediately update the file's timestamp to reduce racyness between worker processes
|
|
169
176
|
# Path().touch() also creates the file if it doesn't exist yet
|
|
170
177
|
pathlib.Path(cleanup_timestamp_file).touch(exist_ok=True)
|
|
@@ -319,6 +326,8 @@ class FileCache:
|
|
|
319
326
|
except Exception as exc:
|
|
320
327
|
print(f"FileCache: Error while removing empty dir {root}: {type(exc).__name__}: {exc}")
|
|
321
328
|
|
|
329
|
+
return CleanupResult(freed=cur_expected_free - disk_usage.free)
|
|
330
|
+
|
|
322
331
|
def handle_cached_files_in_config(self, config: Any) -> Tuple[Any, List[str]]:
|
|
323
332
|
"""
|
|
324
333
|
:param config: some config, e.g. dict, or any nested structure
|
|
@@ -445,6 +454,21 @@ class FileCache:
|
|
|
445
454
|
return True
|
|
446
455
|
|
|
447
456
|
|
|
457
|
+
class CleanupResult:
|
|
458
|
+
"""
|
|
459
|
+
Result from :func:`FileCache.cleanup`.
|
|
460
|
+
"""
|
|
461
|
+
|
|
462
|
+
def __init__(self, *, freed: int = 0, abort_reason: Optional[str] = None):
|
|
463
|
+
self.freed = freed
|
|
464
|
+
self.abort_reason = abort_reason
|
|
465
|
+
|
|
466
|
+
def __repr__(self):
|
|
467
|
+
if self.abort_reason:
|
|
468
|
+
return f"CleanupResult(abort_reason={self.abort_reason})"
|
|
469
|
+
return f"CleanupResult(freed={human_bytes_size(self.freed)})"
|
|
470
|
+
|
|
471
|
+
|
|
448
472
|
def get_instance(config: Optional[Config] = None) -> FileCache:
|
|
449
473
|
"""
|
|
450
474
|
Returns a file cache instance potentially initialized by the global config.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
returnn/PKG-INFO,sha256=
|
|
1
|
+
returnn/PKG-INFO,sha256=MD6673KZA1OY8q_YBhvjfLXMKd_KFKiIvwlmxfBnpPg,5213
|
|
2
2
|
returnn/__init__.py,sha256=biBtRsM0WZ406vShaeH-9WFoqJ8XwTbn6g0EeFJ7l8E,1012
|
|
3
3
|
returnn/__main__.py,sha256=lHyZcu_0yc9f7Vf_Kfdy9PmeU0T76XVXnpalHi5WKro,31740
|
|
4
4
|
returnn/__old_mod_loader__.py,sha256=nvsNY-xELdS_IPNkv66Q9Rmvg4dbGW0-EBRDcCmctos,7654
|
|
5
5
|
returnn/__setup__.py,sha256=22kQn2fh11iPM0hLb2Fy5sLmoU1JGvmDxXRYuRgQkwU,4659
|
|
6
|
-
returnn/_setup_info_generated.py,sha256=
|
|
6
|
+
returnn/_setup_info_generated.py,sha256=MTx6vE62qJKlRDxtV-QEtWFWT82-UqyQn1Yxh-v275Y,77
|
|
7
7
|
returnn/config.py,sha256=3tmKhB6FnQZaNdtcYsiB61JnEY--iZ2qmJ4yq0b6tE0,29140
|
|
8
8
|
returnn/forward_iface.py,sha256=A_OJiaXsX4MlXQRzST86ylyxSUZbC402PQL1REcqHjM,911
|
|
9
9
|
returnn/learning_rate_control.py,sha256=ZvWryAn_tv9DhV8sh1LV3eE34Yltl3On3mYZAG4hR9s,34684
|
|
@@ -239,7 +239,7 @@ returnn/util/better_exchook.py,sha256=39yvRecluDgYhViwSkaQ8crJ_cBWI63KeEGuK4RKe5
|
|
|
239
239
|
returnn/util/bpe.py,sha256=LWFhICZsEOnMwNws0lybPNzKRX6rSr8yKCvP65vjl9Y,19656
|
|
240
240
|
returnn/util/debug.py,sha256=wuRzdg9zB84WWCGyTjmRR_zYypu8gXxlc0nZ6si9OC8,28224
|
|
241
241
|
returnn/util/debug_helpers.py,sha256=0EINLK4uLtoSt5_kHs1M2NIFpMd0S7i4c4rx90U4fJk,2914
|
|
242
|
-
returnn/util/file_cache.py,sha256=
|
|
242
|
+
returnn/util/file_cache.py,sha256=Wyx9u1P59PAo4HouVPh6uaGQeFIXGZHshDyvcRn4YlM,28786
|
|
243
243
|
returnn/util/fsa.py,sha256=k2lJ8tyf_g44Xk1EPVLwDwpP4spoMTqIigDVOWocQHY,59177
|
|
244
244
|
returnn/util/literal_py_to_pickle.py,sha256=3dnjWPeeiDT2xp4bRDgIf9yddx7b1AG7mOKEn_jiSl8,2173
|
|
245
245
|
returnn/util/lru_cache.py,sha256=7Q5H3a8b07E8e1iB7PA9jCpRnxMJZOFS2KO07cy0gqk,11446
|
|
@@ -254,8 +254,8 @@ returnn/util/sig_proc.py,sha256=Tjz0VOAVyqu2qDCF5HZ1JjALjcFsHcNkcd96WgZeKfE,7265
|
|
|
254
254
|
returnn/util/task_system.py,sha256=y4sMVXQ25Qd2z0rx03uOlXlkE-jbCYC1Sjfn-XlraVU,26003
|
|
255
255
|
returnn/util/train_proc_manager.py,sha256=Pjht28k6uz6BNQ47uW6Gf880iyq5q4wx7P_K2tmoAM8,3266
|
|
256
256
|
returnn/util/watch_memory.py,sha256=BR5P2kvBN6UI81cE0_1WAA6Hd1SByLbBaiDxvLhPOew,4213
|
|
257
|
-
returnn-1.
|
|
258
|
-
returnn-1.
|
|
259
|
-
returnn-1.
|
|
260
|
-
returnn-1.
|
|
261
|
-
returnn-1.
|
|
257
|
+
returnn-1.20251013.3246.dist-info/LICENSE,sha256=ywBD_U2aD4vpuoIgNAsjIGBYydl0tVKll3De0Z8s77c,11041
|
|
258
|
+
returnn-1.20251013.3246.dist-info/METADATA,sha256=MD6673KZA1OY8q_YBhvjfLXMKd_KFKiIvwlmxfBnpPg,5213
|
|
259
|
+
returnn-1.20251013.3246.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
260
|
+
returnn-1.20251013.3246.dist-info/top_level.txt,sha256=Lsn4WZc5Pbfk0-xDQOgnFCxOoqxL4CyeM3N1TFbJncw,8
|
|
261
|
+
returnn-1.20251013.3246.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|