nshtrainer 0.11.10__py3-none-any.whl → 0.11.12__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.
- nshtrainer/_checkpoint/metadata.py +5 -1
- nshtrainer/_checkpoint/saver.py +11 -8
- nshtrainer/callbacks/checkpoint/_base.py +1 -0
- nshtrainer/callbacks/checkpoint/on_exception_checkpoint.py +3 -0
- nshtrainer/model/config.py +2 -30
- {nshtrainer-0.11.10.dist-info → nshtrainer-0.11.12.dist-info}/METADATA +1 -1
- {nshtrainer-0.11.10.dist-info → nshtrainer-0.11.12.dist-info}/RECORD +8 -8
- {nshtrainer-0.11.10.dist-info → nshtrainer-0.11.12.dist-info}/WHEEL +0 -0
|
@@ -137,7 +137,11 @@ def _link_checkpoint_metadata(checkpoint_path: Path, linked_checkpoint_path: Pat
|
|
|
137
137
|
linked_path = linked_checkpoint_path.with_suffix(METADATA_PATH_SUFFIX)
|
|
138
138
|
try:
|
|
139
139
|
try:
|
|
140
|
-
linked_path.symlink_to(path)
|
|
140
|
+
# linked_path.symlink_to(path)
|
|
141
|
+
# We should store the path as a relative path
|
|
142
|
+
# to the metadata file to avoid issues with
|
|
143
|
+
# moving the checkpoint directory
|
|
144
|
+
linked_path.symlink_to(path.relative_to(linked_path.parent))
|
|
141
145
|
except OSError:
|
|
142
146
|
# on Windows, special permissions are required to create symbolic links as a regular user
|
|
143
147
|
# fall back to copying the file
|
nshtrainer/_checkpoint/saver.py
CHANGED
|
@@ -12,22 +12,25 @@ def _link_checkpoint(
|
|
|
12
12
|
linkpath: str | Path | os.PathLike,
|
|
13
13
|
*,
|
|
14
14
|
metadata: bool,
|
|
15
|
+
remove_existing: bool = True,
|
|
15
16
|
):
|
|
16
17
|
if not isinstance(filepath, Path):
|
|
17
18
|
filepath = Path(filepath)
|
|
18
19
|
if not isinstance(linkpath, Path):
|
|
19
20
|
linkpath = Path(linkpath)
|
|
20
21
|
|
|
21
|
-
if
|
|
22
|
-
if linkpath.
|
|
23
|
-
linkpath.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
if remove_existing:
|
|
23
|
+
if linkpath.exists():
|
|
24
|
+
if linkpath.is_symlink() or linkpath.is_file():
|
|
25
|
+
linkpath.unlink()
|
|
26
|
+
elif linkpath.is_dir():
|
|
27
|
+
shutil.rmtree(linkpath)
|
|
28
|
+
|
|
29
|
+
if metadata:
|
|
30
|
+
_remove_checkpoint_metadata(linkpath)
|
|
27
31
|
|
|
28
32
|
try:
|
|
29
|
-
|
|
30
|
-
linkpath.symlink_to(target_path)
|
|
33
|
+
linkpath.symlink_to(filepath.relative_to(linkpath.parent))
|
|
31
34
|
except OSError:
|
|
32
35
|
# on Windows, special permissions are required to create symbolic links as a regular user
|
|
33
36
|
# fall back to copying the file
|
nshtrainer/model/config.py
CHANGED
|
@@ -3,7 +3,6 @@ import logging
|
|
|
3
3
|
import os
|
|
4
4
|
import string
|
|
5
5
|
import time
|
|
6
|
-
import warnings
|
|
7
6
|
from abc import ABC, abstractmethod
|
|
8
7
|
from collections.abc import Iterable, Sequence
|
|
9
8
|
from datetime import timedelta
|
|
@@ -50,10 +49,6 @@ from ..util._environment_info import EnvironmentConfig
|
|
|
50
49
|
log = logging.getLogger(__name__)
|
|
51
50
|
|
|
52
51
|
|
|
53
|
-
class IdSeedWarning(Warning):
|
|
54
|
-
pass
|
|
55
|
-
|
|
56
|
-
|
|
57
52
|
class BaseProfilerConfig(C.Config, ABC):
|
|
58
53
|
dirpath: str | Path | None = None
|
|
59
54
|
"""
|
|
@@ -1478,35 +1473,12 @@ class BaseConfig(C.Config):
|
|
|
1478
1473
|
_rng: ClassVar[np.random.Generator | None] = None
|
|
1479
1474
|
|
|
1480
1475
|
@staticmethod
|
|
1481
|
-
def generate_id(
|
|
1482
|
-
*,
|
|
1483
|
-
length: int = 8,
|
|
1484
|
-
ignore_rng: bool = False,
|
|
1485
|
-
) -> str:
|
|
1476
|
+
def generate_id(*, length: int = 8) -> str:
|
|
1486
1477
|
"""
|
|
1487
1478
|
Generate a random ID of specified length.
|
|
1488
1479
|
|
|
1489
|
-
Args:
|
|
1490
|
-
length (int): The length of the generated ID. Default is 8.
|
|
1491
|
-
ignore_rng (bool): If True, ignore the global random number generator and use a new one. Default is False.
|
|
1492
|
-
|
|
1493
|
-
Returns:
|
|
1494
|
-
str: The generated random ID.
|
|
1495
|
-
|
|
1496
|
-
Raises:
|
|
1497
|
-
IdSeedWarning: If the global random number generator is None and ignore_rng is False.
|
|
1498
|
-
|
|
1499
|
-
Notes:
|
|
1500
|
-
- The generated IDs will not be reproducible if the global random number generator is None and ignore_rng is False.
|
|
1501
|
-
- To ensure reproducibility, call BaseConfig.set_seed(...) before generating any IDs.
|
|
1502
1480
|
"""
|
|
1503
|
-
rng
|
|
1504
|
-
if rng is None:
|
|
1505
|
-
warnings.warn(
|
|
1506
|
-
"BaseConfig._rng is None. The generated IDs will not be reproducible. "
|
|
1507
|
-
+ "To fix this, call BaseConfig.set_seed(...) before generating any IDs.",
|
|
1508
|
-
category=IdSeedWarning,
|
|
1509
|
-
)
|
|
1481
|
+
if (rng := BaseConfig._rng) is None:
|
|
1510
1482
|
rng = np.random.default_rng()
|
|
1511
1483
|
|
|
1512
1484
|
alphabet = list(string.ascii_lowercase + string.digits)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
nshtrainer/__init__.py,sha256=39loiLLXbaGiozEsAn8mPHopxaPsek8JsgR9DD2gxtY,583
|
|
2
2
|
nshtrainer/_checkpoint/loader.py,sha256=DSaNR8194kWon4O1svslNsCcN_8vlyLbF0LNCPfUpzI,13789
|
|
3
|
-
nshtrainer/_checkpoint/metadata.py,sha256=
|
|
4
|
-
nshtrainer/_checkpoint/saver.py,sha256=
|
|
3
|
+
nshtrainer/_checkpoint/metadata.py,sha256=onmetLp5eKbA86abq1PTkwAOO7bWj7Pa1EGUjl2TEjQ,5153
|
|
4
|
+
nshtrainer/_checkpoint/saver.py,sha256=DkbCH0YeOJ71m32vAARiQdGBf0hvwwdoAV8LOFGy-0Y,1428
|
|
5
5
|
nshtrainer/_experimental/__init__.py,sha256=2tQIcrWT8U8no_AeBTYnozaTmxN40kuAJdGQ4b-PoWM,120
|
|
6
6
|
nshtrainer/_experimental/flops/__init__.py,sha256=edo9Ez3LlrnxkNRX9W6YBhPkRPKYGLpkpnl5gx7sEX8,1550
|
|
7
7
|
nshtrainer/_experimental/flops/flop_counter.py,sha256=-sL0Fy6poXa__hyzUMdZScjPULp4coQELQpPU6p6dXU,25736
|
|
@@ -11,10 +11,10 @@ nshtrainer/callbacks/_throughput_monitor_callback.py,sha256=aJo_11rc4lo0IYOd-kHm
|
|
|
11
11
|
nshtrainer/callbacks/actsave.py,sha256=qbnaKts4_dvjPeAaPtv7Ds12_vEWzaHUfg_--49NB9I,4041
|
|
12
12
|
nshtrainer/callbacks/base.py,sha256=UnlYZAqSb8UwBJR-N5-XunxFx2yZjZ4lyGqUfhbCRlI,3555
|
|
13
13
|
nshtrainer/callbacks/checkpoint/__init__.py,sha256=g-3zIthupERKqWZQw-A_busQPaPRkto6iHBV-M7nK1Y,527
|
|
14
|
-
nshtrainer/callbacks/checkpoint/_base.py,sha256=
|
|
14
|
+
nshtrainer/callbacks/checkpoint/_base.py,sha256=wb5ARqqSslZXB5FSwNd9a_7qtt4-F9dC7E1vNHKCK1o,5994
|
|
15
15
|
nshtrainer/callbacks/checkpoint/best_checkpoint.py,sha256=ySeyALxc-YJaS5IhmW0MkAhr41Mxsm_BllHuufXGy4Y,2067
|
|
16
16
|
nshtrainer/callbacks/checkpoint/last_checkpoint.py,sha256=CM8f37dwaYHkjQFfJNTZTzSoF45zEjFRm-Fg1CzYmP4,1037
|
|
17
|
-
nshtrainer/callbacks/checkpoint/on_exception_checkpoint.py,sha256=
|
|
17
|
+
nshtrainer/callbacks/checkpoint/on_exception_checkpoint.py,sha256=ctT88EGT22_t_6tr5r7Sfo43cuve6XeroBnBYRMPOus,3372
|
|
18
18
|
nshtrainer/callbacks/early_stopping.py,sha256=LGn3rdbvkFfUo9kwMzK4eMGlPAqD9uFdowDx6VdfozQ,3761
|
|
19
19
|
nshtrainer/callbacks/ema.py,sha256=8-WHmKFP3VfnzMviJaIFmVD9xHPqIPmq9NRF5xdu3c8,12131
|
|
20
20
|
nshtrainer/callbacks/finite_checks.py,sha256=gJC_RUr3ais3FJI0uB6wUZnDdE3WRwCix3ppA3PwQXA,2077
|
|
@@ -54,7 +54,7 @@ nshtrainer/metrics/__init__.py,sha256=ObLIELGguIEcUpRsUkqh1ltrvZii6vglTpJGrPvoy0
|
|
|
54
54
|
nshtrainer/metrics/_config.py,sha256=jgRBfDAQLFTW7AiUY7CRtdfts6CR6keeuqm0FFMWCzQ,1288
|
|
55
55
|
nshtrainer/model/__init__.py,sha256=RlGW5a46DZcqK6cYICYxDaKpZIEj-8zLxoMrl432tno,1429
|
|
56
56
|
nshtrainer/model/base.py,sha256=AXRfEsFAT0Ln7zjYVPU5NgtHS_c8FZM-M4pyLamO7OA,17516
|
|
57
|
-
nshtrainer/model/config.py,sha256=
|
|
57
|
+
nshtrainer/model/config.py,sha256=3qSaXNjpKnxF60LbfpONsVhjtrteLEdHkjb5KAhAnIk,52757
|
|
58
58
|
nshtrainer/model/modules/callback.py,sha256=K0-cyEtBcQhI7Q2e-AGTE8T-GghUPY9DYmneU6ULV6g,6401
|
|
59
59
|
nshtrainer/model/modules/debug.py,sha256=Yy7XEdPou9BkCsD5hJchwJGmCVGrfUru5g9VjPM4uAw,1120
|
|
60
60
|
nshtrainer/model/modules/distributed.py,sha256=ABpR9d-3uBS_fivfy_WYW-dExW6vp5BPaoPQnOudHng,1725
|
|
@@ -82,6 +82,6 @@ nshtrainer/util/seed.py,sha256=Or2wMPsnQxfnZ2xfBiyMcHFIUt3tGTNeMMyOEanCkqs,280
|
|
|
82
82
|
nshtrainer/util/slurm.py,sha256=rofIU26z3SdL79SF45tNez6juou1cyDLz07oXEZb9Hg,1566
|
|
83
83
|
nshtrainer/util/typed.py,sha256=NGuDkDzFlc1fAoaXjOFZVbmj0mRFjsQi1E_hPa7Bn5U,128
|
|
84
84
|
nshtrainer/util/typing_utils.py,sha256=8ptjSSLZxlmy4FY6lzzkoGoF5fGNClo8-B_c0XHQaNU,385
|
|
85
|
-
nshtrainer-0.11.
|
|
86
|
-
nshtrainer-0.11.
|
|
87
|
-
nshtrainer-0.11.
|
|
85
|
+
nshtrainer-0.11.12.dist-info/METADATA,sha256=Lthmwj2EpbkCNWlDg2n7z4zS197Pn5Kt1aUMayB70oo,861
|
|
86
|
+
nshtrainer-0.11.12.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
87
|
+
nshtrainer-0.11.12.dist-info/RECORD,,
|
|
File without changes
|