nshtrainer 0.16.1__py3-none-any.whl → 0.17.1__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.
@@ -10,6 +10,8 @@ import nshconfig as C
10
10
  import numpy as np
11
11
  import torch
12
12
 
13
+ from ..util._environment_info import EnvironmentConfig
14
+
13
15
  if TYPE_CHECKING:
14
16
  from ..model import BaseConfig, LightningModuleBase
15
17
  from ..trainer.trainer import Trainer
@@ -36,13 +38,13 @@ class CheckpointMetadata(C.Config):
36
38
  global_step: int
37
39
  training_time: datetime.timedelta
38
40
  metrics: dict[str, Any]
39
- environment: dict[str, Any]
41
+ environment: EnvironmentConfig
40
42
 
41
- hparams: dict[str, Any] | None
43
+ hparams: Any
42
44
 
43
45
  @classmethod
44
46
  def from_file(cls, path: Path):
45
- return cls.model_validate_json(path.read_text())
47
+ return cls.model_validate_json(path.read_text(encoding="utf-8"))
46
48
 
47
49
  @classmethod
48
50
  def from_ckpt_path(cls, checkpoint_path: Path):
@@ -89,8 +91,8 @@ def _generate_checkpoint_metadata(
89
91
  global_step=trainer.global_step,
90
92
  training_time=training_time,
91
93
  metrics=metrics,
92
- environment=config.environment.model_dump(mode="json"),
93
- hparams=config.model_dump(mode="json"),
94
+ environment=config.environment,
95
+ hparams=config.model_dump(),
94
96
  )
95
97
 
96
98
 
@@ -107,9 +109,9 @@ def _write_checkpoint_metadata(
107
109
 
108
110
  # Write the metadata to the checkpoint directory
109
111
  try:
110
- metadata_path.write_text(metadata.model_dump_json(indent=4))
111
- except Exception as e:
112
- log.warning(f"Failed to write metadata to {checkpoint_path}: {e}")
112
+ metadata_path.write_text(metadata.model_dump_json(indent=4), encoding="utf-8")
113
+ except Exception:
114
+ log.exception(f"Failed to write metadata to {checkpoint_path}")
113
115
  else:
114
116
  log.debug(f"Checkpoint metadata written to {checkpoint_path}")
115
117
 
@@ -118,8 +120,8 @@ def _remove_checkpoint_metadata(checkpoint_path: Path):
118
120
  path = checkpoint_path.with_suffix(CheckpointMetadata.PATH_SUFFIX)
119
121
  try:
120
122
  path.unlink(missing_ok=True)
121
- except Exception as e:
122
- log.warning(f"Failed to remove {path}: {e}")
123
+ except Exception:
124
+ log.exception(f"Failed to remove {path}")
123
125
  else:
124
126
  log.debug(f"Removed {path}")
125
127
 
@@ -142,8 +144,8 @@ def _link_checkpoint_metadata(checkpoint_path: Path, linked_checkpoint_path: Pat
142
144
  # on Windows, special permissions are required to create symbolic links as a regular user
143
145
  # fall back to copying the file
144
146
  shutil.copy(path, linked_path)
145
- except Exception as e:
146
- log.warning(f"Failed to link {path} to {linked_path}: {e}")
147
+ except Exception:
148
+ log.exception(f"Failed to link {path} to {linked_path}")
147
149
  else:
148
150
  log.debug(f"Linked {path} to {linked_path}")
149
151
 
@@ -429,12 +429,12 @@ class EnvironmentPackageConfig(C.Config):
429
429
  version=clean_version,
430
430
  path=Path(str(f)) if (f := dist.locate_file("")) else None,
431
431
  summary=metadata["Summary"] if "Summary" in metadata else None,
432
- author=metadata["Author"] if "Summary" in metadata else None,
433
- license=metadata["License"] if "Summary" in metadata else None,
432
+ author=metadata["Author"] if "Author" in metadata else None,
433
+ license=metadata["License"] if "License" in metadata else None,
434
434
  requires=requires,
435
435
  )
436
- except Exception as e:
437
- log.warning(f"Error processing package {dist.name}: {str(e)}")
436
+ except Exception:
437
+ log.exception(f"Error processing package {dist.name}")
438
438
 
439
439
  except ImportError:
440
440
  log.warning(
@@ -672,8 +672,8 @@ class GitRepositoryConfig(C.Config):
672
672
  draft.is_dirty = repo.is_dirty()
673
673
  except git.InvalidGitRepositoryError:
674
674
  draft.is_git_repo = False
675
- except Exception as e:
676
- log.warning(f"Failed to get Git repository information: {e}")
675
+ except Exception:
676
+ log.exception("Failed to get Git repository information")
677
677
  draft.is_git_repo = None
678
678
 
679
679
  return draft.finalize()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nshtrainer
3
- Version: 0.16.1
3
+ Version: 0.17.1
4
4
  Summary:
5
5
  Author: Nima Shoghi
6
6
  Author-email: nimashoghi@gmail.com
@@ -1,6 +1,6 @@
1
1
  nshtrainer/__init__.py,sha256=39loiLLXbaGiozEsAn8mPHopxaPsek8JsgR9DD2gxtY,583
2
2
  nshtrainer/_checkpoint/loader.py,sha256=myFObRsPdb8jBncMK73vjr5FDJIfKhF86Ec_kSjXtwg,13837
3
- nshtrainer/_checkpoint/metadata.py,sha256=z3gi_J_YDNNtBw1OZ08LBECkcoc9rIydnTKvFOOoG4c,5131
3
+ nshtrainer/_checkpoint/metadata.py,sha256=FGVYqqHp5rCETcPfaoSZmGIPapE4kdYJCKSutTRERQI,5147
4
4
  nshtrainer/_checkpoint/saver.py,sha256=DkbCH0YeOJ71m32vAARiQdGBf0hvwwdoAV8LOFGy-0Y,1428
5
5
  nshtrainer/_experimental/__init__.py,sha256=pEXPyI184UuDHvfh4p9Kg9nQZQZI41e4_HvNd4BK-yg,81
6
6
  nshtrainer/callbacks/__init__.py,sha256=4qocBDzQbLLhhbIEfvbA3SQB_Dy9ZJH7keMwPay-ZS8,2359
@@ -77,13 +77,13 @@ nshtrainer/trainer/_runtime_callback.py,sha256=sd2cUdRJG-UCdQr9ruZvEYpNGNF1t2W2f
77
77
  nshtrainer/trainer/checkpoint_connector.py,sha256=F2tkHogbMAa5U7335sm77sZBkjEDa5v46XbJCH9Mg6c,2167
78
78
  nshtrainer/trainer/signal_connector.py,sha256=2EzkVktlasl8PgWAKNLDZRUMY__gRlDy1HdinAU-tfU,10740
79
79
  nshtrainer/trainer/trainer.py,sha256=jIqiNrq1I0f5pQP7lHshtgjCAYfpoWPoqwS74LHU9iM,17148
80
- nshtrainer/util/_environment_info.py,sha256=Nmhls6u5rtMWbeDLGCjEk58efUutc_ONSUg3fs59TSI,24210
80
+ nshtrainer/util/_environment_info.py,sha256=gIdq9TJgzGCdcVzZxjHcwYasJ_HmEGVHbvE-KJVVtWs,24187
81
81
  nshtrainer/util/_useful_types.py,sha256=dwZokFkIe7M5i2GR3nQ9A1lhGw06DMAFfH5atyquqSA,8000
82
82
  nshtrainer/util/environment.py,sha256=AeW_kLl-N70wmb6L_JLz1wRj0kA70xs6RCmc9iUqczE,4159
83
83
  nshtrainer/util/seed.py,sha256=Or2wMPsnQxfnZ2xfBiyMcHFIUt3tGTNeMMyOEanCkqs,280
84
84
  nshtrainer/util/slurm.py,sha256=rofIU26z3SdL79SF45tNez6juou1cyDLz07oXEZb9Hg,1566
85
85
  nshtrainer/util/typed.py,sha256=NGuDkDzFlc1fAoaXjOFZVbmj0mRFjsQi1E_hPa7Bn5U,128
86
86
  nshtrainer/util/typing_utils.py,sha256=8ptjSSLZxlmy4FY6lzzkoGoF5fGNClo8-B_c0XHQaNU,385
87
- nshtrainer-0.16.1.dist-info/METADATA,sha256=SQ2uzBMs4f-pYgabVgI9EErqge_LtQ9-RTz2_mTskDU,885
88
- nshtrainer-0.16.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
89
- nshtrainer-0.16.1.dist-info/RECORD,,
87
+ nshtrainer-0.17.1.dist-info/METADATA,sha256=yFOvBuWFb0naLc6p82HVodctRPi1AAzWIb3wwa5Vq-I,885
88
+ nshtrainer-0.17.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
89
+ nshtrainer-0.17.1.dist-info/RECORD,,