nshtrainer 0.14.4__py3-none-any.whl → 0.15.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.
@@ -1,9 +1,10 @@
1
+ import importlib.metadata
1
2
  import logging
2
3
  from typing import TYPE_CHECKING, Literal
3
4
 
4
5
  import nshconfig as C
5
- import pkg_resources
6
6
  from lightning.pytorch import Callback, LightningModule, Trainer
7
+ from packaging import version
7
8
  from typing_extensions import override
8
9
 
9
10
  from ..callbacks import WandbWatchConfig
@@ -120,9 +121,8 @@ class WandbLoggerConfig(CallbackConfigBase, BaseLoggerConfig):
120
121
  import wandb # type: ignore
121
122
 
122
123
  # The minimum version that supports the new backend is 0.17.5
123
- if pkg_resources.parse_version(
124
- wandb.__version__
125
- ) < pkg_resources.parse_version("0.17.5"):
124
+ wandb_version = version.parse(importlib.metadata.version("wandb"))
125
+ if wandb_version < version.parse("0.17.5"):
126
126
  log.warning(
127
127
  "The version of WandB installed does not support the `wandb-core` backend "
128
128
  f"(expected version >= 0.17.5, found version {wandb.__version__}). "
@@ -40,7 +40,6 @@ def main():
40
40
 
41
41
  if args.exclude_std:
42
42
  std_libs = set(sys.stdlib_module_names)
43
- std_libs.update({"pkg_resources"})
44
43
  all_imports = all_imports - std_libs
45
44
 
46
45
  for package in sorted(all_imports):
@@ -1,4 +1,5 @@
1
1
  import getpass
2
+ import importlib.metadata
2
3
  import inspect
3
4
  import logging
4
5
  import os
@@ -12,6 +13,7 @@ from typing import TYPE_CHECKING, Any, cast
12
13
  import nshconfig as C
13
14
  import psutil
14
15
  import torch
16
+ from packaging import version
15
17
  from typing_extensions import Self
16
18
 
17
19
  from .slurm import parse_slurm_node_list
@@ -398,23 +400,46 @@ class EnvironmentPackageConfig(C.Config):
398
400
 
399
401
  @classmethod
400
402
  def from_current_environment(cls):
401
- # Add Python package information
402
403
  python_packages: dict[str, Self] = {}
403
404
  try:
404
- import pkg_resources
405
-
406
- for package in pkg_resources.working_set:
407
- python_packages[package.key] = cls(
408
- name=package.project_name,
409
- version=package.version,
410
- path=Path(package.location) if package.location else None,
411
- summary=getattr(package, "summary", None),
412
- author=getattr(package, "author", None),
413
- license=getattr(package, "license", None),
414
- requires=[str(req) for req in package.requires()],
415
- )
405
+ for dist in importlib.metadata.distributions():
406
+ try:
407
+ # Get package metadata
408
+ metadata = dist.metadata
409
+
410
+ # Parse the version, stripping any local version identifier
411
+ pkg_version = version.parse(dist.version)
412
+ clean_version = (
413
+ f"{pkg_version.major}.{pkg_version.minor}.{pkg_version.micro}"
414
+ )
415
+
416
+ # Get requirements
417
+ requires = []
418
+ for req in dist.requires or []:
419
+ try:
420
+ requires.append(str(req))
421
+ except ValueError:
422
+ # If there's an invalid requirement, we'll skip it
423
+ log.warning(
424
+ f"Skipping invalid requirement for {dist.name}: {req}"
425
+ )
426
+
427
+ python_packages[dist.name] = cls(
428
+ name=dist.name,
429
+ version=clean_version,
430
+ path=Path(str(f)) if (f := dist.locate_file("")) else None,
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,
434
+ requires=requires,
435
+ )
436
+ except Exception as e:
437
+ log.warning(f"Error processing package {dist.name}: {str(e)}")
438
+
416
439
  except ImportError:
417
- log.warning("pkg_resources not available, skipping package information")
440
+ log.warning(
441
+ "importlib.metadata not available, skipping package information"
442
+ )
418
443
 
419
444
  return python_packages
420
445
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nshtrainer
3
- Version: 0.14.4
3
+ Version: 0.15.1
4
4
  Summary:
5
5
  Author: Nima Shoghi
6
6
  Author-email: nimashoghi@gmail.com
@@ -16,6 +16,7 @@ Requires-Dist: nshconfig
16
16
  Requires-Dist: nshrunner
17
17
  Requires-Dist: nshutils
18
18
  Requires-Dist: numpy
19
+ Requires-Dist: packaging
19
20
  Requires-Dist: psutil
20
21
  Requires-Dist: pytorch-lightning
21
22
  Requires-Dist: tensorboard ; extra == "extra"
@@ -47,7 +47,7 @@ nshtrainer/loggers/__init__.py,sha256=C_xk0A3_qKbNdTmzK85AgjRHFD3w-jPRS2ig-iPhfE
47
47
  nshtrainer/loggers/_base.py,sha256=xiZKEK0ALJkcqf4OpVNRY0QbZsamR_WR7x7m_68YHXQ,705
48
48
  nshtrainer/loggers/csv.py,sha256=D_lYyd94bZ8jAgnRo-ARtFgVcInaD9zktxtsUD9RWCI,1052
49
49
  nshtrainer/loggers/tensorboard.py,sha256=wL2amRSdP68zbslZvBeM0ZQBnjF3hIKsz-_lBbdomaM,2216
50
- nshtrainer/loggers/wandb.py,sha256=QteSPfaBWxQ-FuuaF6_rKxw8twJdg_6oHoTQlbqvrXk,5079
50
+ nshtrainer/loggers/wandb.py,sha256=FPwbf618AYmuPzHdhd1ZFhJ8qDjwTUiSe7cm7g3KCyM,5112
51
51
  nshtrainer/lr_scheduler/__init__.py,sha256=uEvgaFAs-4s_bAEMaildy0GT6OvgpgOEKTuzqutESHE,736
52
52
  nshtrainer/lr_scheduler/_base.py,sha256=7xOIuxQ86YHbFWG5a3gX46emQj1WN_LaY4-i0Q1TDBg,3659
53
53
  nshtrainer/lr_scheduler/linear_warmup_cosine.py,sha256=mn6cyizyI_stkXtg6zxIEGF9btIxMRWigUHUTlUYCSw,5221
@@ -71,19 +71,19 @@ nshtrainer/nn/module_list.py,sha256=fb2u5Rqdjff8Pekyr9hkCPkBorQ-fldzzFAjsgWAm30,
71
71
  nshtrainer/nn/nonlinearity.py,sha256=owtU4kh4G98psD0axOJWVfBhm-OtJVgFM-TXSHmbNPU,3625
72
72
  nshtrainer/optimizer.py,sha256=kuJEA1pvB3y1FcsfhAoOJujVqEZqFHlmYO8GW6JeA1g,1527
73
73
  nshtrainer/runner.py,sha256=USAjrExHkN5oVNVunsoPnLxfQrEHSaa54S3RipOe544,3605
74
- nshtrainer/scripts/find_packages.py,sha256=FbdlfmAefttFSMfaT0A46a-oHLP_ioaQKihwBfBeWeA,1467
74
+ nshtrainer/scripts/find_packages.py,sha256=ixYivZobumyyGsf2B9oYMLyLTRcBzY_vUv-u3bNW-hs,1424
75
75
  nshtrainer/trainer/__init__.py,sha256=P2rmr8oBVTHk-HJHYPcUwWqDEArMbPR4_rPpATbWK3E,40
76
76
  nshtrainer/trainer/_runtime_callback.py,sha256=sd2cUdRJG-UCdQr9ruZvEYpNGNF1t2W2fuxwwVlQD9E,4164
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=M97phnALfG18VxkMLoDr5AKFf4UaPBdc6S2BghdBtas,17103
80
- nshtrainer/util/_environment_info.py,sha256=yPtAbgjCY4tkvh5wp9sjNsF0Z45TYwzEAM_N2_b5BbY,23123
80
+ nshtrainer/util/_environment_info.py,sha256=Nmhls6u5rtMWbeDLGCjEk58efUutc_ONSUg3fs59TSI,24210
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.14.4.dist-info/METADATA,sha256=Xg7ON7o-nR8N-4C8E59k2jsvIaleKPDas5VpdTVyr6s,860
88
- nshtrainer-0.14.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
89
- nshtrainer-0.14.4.dist-info/RECORD,,
87
+ nshtrainer-0.15.1.dist-info/METADATA,sha256=glwnOrFiNjiz0Qf_7x1wU8s4XTd_Hx0F3qseDNONjyI,885
88
+ nshtrainer-0.15.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
89
+ nshtrainer-0.15.1.dist-info/RECORD,,