nshtrainer 0.14.4__py3-none-any.whl → 0.15.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.
@@ -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.0
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"
@@ -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=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.0.dist-info/METADATA,sha256=GWle2LcHPRsK2Ygf8jgf1eAUPa7eaAdiZT_NkVvauNw,885
88
+ nshtrainer-0.15.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
89
+ nshtrainer-0.15.0.dist-info/RECORD,,