nshtrainer 0.36.0__py3-none-any.whl → 0.37.0__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.
@@ -30,6 +30,8 @@ def _link_checkpoint(
30
30
  linkpath.unlink(missing_ok=True)
31
31
  except Exception:
32
32
  log.warning(f"Failed to remove {linkpath}", exc_info=True)
33
+ else:
34
+ log.debug(f"Removed {linkpath=}")
33
35
 
34
36
  if metadata:
35
37
  _remove_checkpoint_metadata(linkpath)
nshtrainer/util/path.py CHANGED
@@ -80,11 +80,25 @@ def try_symlink_or_copy(
80
80
  link_path: Path,
81
81
  target_is_directory: bool = False,
82
82
  relative: bool = True,
83
+ remove_existing: bool = True,
83
84
  ):
84
85
  """
85
86
  Symlinks on Unix, copies on Windows.
86
87
  """
87
88
 
89
+ # If the link already exists, remove it
90
+ if remove_existing:
91
+ try:
92
+ if link_path.exists():
93
+ if link_path.is_dir():
94
+ shutil.rmtree(link_path)
95
+ else:
96
+ link_path.unlink(missing_ok=True)
97
+ except Exception:
98
+ log.warning(f"Failed to remove {link_path}", exc_info=True)
99
+ else:
100
+ log.debug(f"Removed {link_path=}")
101
+
88
102
  symlink_target = get_relative_path(link_path, file_path) if relative else file_path
89
103
  try:
90
104
  if platform.system() == "Windows":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nshtrainer
3
- Version: 0.36.0
3
+ Version: 0.37.0
4
4
  Summary:
5
5
  Author: Nima Shoghi
6
6
  Author-email: nimashoghi@gmail.com
@@ -2,7 +2,7 @@ nshtrainer/__init__.py,sha256=flMI50Hj1Ie8c1YMSUQ759AqtNBQLT_zHaV2J9EUmOs,573
2
2
  nshtrainer/_callback.py,sha256=A1zLsTy4b_wOYnInLLXGSRdHzT2yNa6mPEql-ozm0u0,1013
3
3
  nshtrainer/_checkpoint/loader.py,sha256=5vjg-OFChXJjgiOVv8vnV8nwTscfdDtEdxQRz6uPfDE,14158
4
4
  nshtrainer/_checkpoint/metadata.py,sha256=5D4PgKodzhLsmQvuF3xxkH49epKaegxi4wh_ImDTtns,4737
5
- nshtrainer/_checkpoint/saver.py,sha256=MbX_WjkDtHHAf9Ms-KXDlknkjiPXVoGIe2ciO28AdZ0,1264
5
+ nshtrainer/_checkpoint/saver.py,sha256=xuA9iDpc4wAs4ieYW1eJoJicMn6e5xCeCIEKfVOCvrY,1324
6
6
  nshtrainer/_directory.py,sha256=RjnW6vKTeKlz2vQWT3cG0Jje5BkFXA7HpUubDhcSiq4,2993
7
7
  nshtrainer/_experimental/__init__.py,sha256=pEXPyI184UuDHvfh4p9Kg9nQZQZI41e4_HvNd4BK-yg,81
8
8
  nshtrainer/_hf_hub.py,sha256=0bkXkqhve5D1onMW-fCfuvVKlTn0i6jv_6uMNgZ7OHQ,12974
@@ -94,11 +94,11 @@ nshtrainer/util/config/__init__.py,sha256=o8fwPf_dctE_7CAkT0wNOBkvmxnzYzXeHpLedr
94
94
  nshtrainer/util/config/dtype.py,sha256=JtYjrcBFNBlziJnLAE6QS0QV4PUXhGspYH1hNFrB3ks,1965
95
95
  nshtrainer/util/config/duration.py,sha256=pgIKQ88Dg8y1YAKUvUsNWu9hc9O79kdYBfgmC3a_-kQ,728
96
96
  nshtrainer/util/environment.py,sha256=AeW_kLl-N70wmb6L_JLz1wRj0kA70xs6RCmc9iUqczE,4159
97
- nshtrainer/util/path.py,sha256=VkpuhR4GaZtSFBVqbGAvfjcrU-PR8xwiGzzwFNOWP9c,2995
97
+ nshtrainer/util/path.py,sha256=BmBzqtxGu7w2gTYkxQevdBffu_Crm1dH3TURoqqjR6M,3465
98
98
  nshtrainer/util/seed.py,sha256=Or2wMPsnQxfnZ2xfBiyMcHFIUt3tGTNeMMyOEanCkqs,280
99
99
  nshtrainer/util/slurm.py,sha256=rofIU26z3SdL79SF45tNez6juou1cyDLz07oXEZb9Hg,1566
100
100
  nshtrainer/util/typed.py,sha256=NGuDkDzFlc1fAoaXjOFZVbmj0mRFjsQi1E_hPa7Bn5U,128
101
101
  nshtrainer/util/typing_utils.py,sha256=8ptjSSLZxlmy4FY6lzzkoGoF5fGNClo8-B_c0XHQaNU,385
102
- nshtrainer-0.36.0.dist-info/METADATA,sha256=eWSmYvpViGa536HEJ1zX2IUoRpt-wlgiNmfv8mPm7Yg,916
103
- nshtrainer-0.36.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
104
- nshtrainer-0.36.0.dist-info/RECORD,,
102
+ nshtrainer-0.37.0.dist-info/METADATA,sha256=Rd7HeNaz5lBQa0AspjWyRgFLctqpSfna2R9VnMEUURU,916
103
+ nshtrainer-0.37.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
104
+ nshtrainer-0.37.0.dist-info/RECORD,,