nshtrainer 0.4.1__py3-none-any.whl → 0.5.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.
@@ -0,0 +1,42 @@
1
+ import importlib
2
+ import sys
3
+ from types import ModuleType
4
+
5
+ # The name of your new package
6
+ NEW_PACKAGE = "nshtrainer"
7
+
8
+ # Import the new package
9
+ new_package = importlib.import_module(NEW_PACKAGE)
10
+
11
+
12
+ # Create a custom module class that inherits from ModuleType
13
+ class ProxyModule(ModuleType):
14
+ def __getattr__(self, name):
15
+ return getattr(new_package, name)
16
+
17
+ def __dir__(self):
18
+ return dir(new_package)
19
+
20
+
21
+ # Create a new module instance
22
+ old_module = ProxyModule(__name__)
23
+
24
+ # Copy attributes from new_package to old_module
25
+ for attr in dir(new_package):
26
+ if not attr.startswith("__"):
27
+ setattr(old_module, attr, getattr(new_package, attr))
28
+
29
+ # Replace the module in sys.modules
30
+ sys.modules[__name__] = old_module
31
+
32
+
33
+ # Handle submodule imports
34
+ class SubmoduleProxy:
35
+ def __getattr__(self, name):
36
+ return importlib.import_module(f"{NEW_PACKAGE}.{name}")
37
+
38
+
39
+ # Add submodule handling to the proxy module
40
+ old_module.__class__ = type(
41
+ "ProxyModuleWithSubmodules", (ProxyModule, SubmoduleProxy), {}
42
+ )
nshtrainer/runner.py CHANGED
@@ -59,7 +59,32 @@ class Runner(
59
59
  transforms.append(
60
60
  functools.partial(self._fast_dev_run_transform, n_batches=n_batches)
61
61
  )
62
- return self.local(runs, env=env, transforms=transforms)
62
+ return self.local(
63
+ runs,
64
+ env=env,
65
+ transforms=transforms,
66
+ )
67
+
68
+ def fast_dev_run_generator(
69
+ self,
70
+ runs: Sequence[tuple[TConfig, Unpack[TArguments]]],
71
+ n_batches: int = 1,
72
+ *,
73
+ env: Mapping[str, str] | None = None,
74
+ transforms: list[
75
+ Callable[[TConfig, Unpack[TArguments]], tuple[TConfig, Unpack[TArguments]]]
76
+ ]
77
+ | None = None,
78
+ ):
79
+ transforms = transforms or []
80
+ transforms.append(
81
+ functools.partial(self._fast_dev_run_transform, n_batches=n_batches)
82
+ )
83
+ return self.local_generator(
84
+ runs,
85
+ env=env,
86
+ transforms=transforms,
87
+ )
63
88
 
64
89
  def fast_dev_run_session(
65
90
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nshtrainer
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary:
5
5
  Author: Nima Shoghi
6
6
  Author-email: nimashoghi@gmail.com
@@ -13,7 +13,7 @@ Requires-Dist: lightning
13
13
  Requires-Dist: lovely-numpy (>=0.2.13,<0.3.0)
14
14
  Requires-Dist: lovely-tensors (>=0.1.16,<0.2.0)
15
15
  Requires-Dist: nshconfig (>=0.2.0,<0.3.0)
16
- Requires-Dist: nshrunner (>=0.5.5,<0.6.0)
16
+ Requires-Dist: nshrunner (>=0.6.0,<0.7.0)
17
17
  Requires-Dist: nshutils (>=0.3.0,<0.4.0)
18
18
  Requires-Dist: numpy
19
19
  Requires-Dist: pytorch-lightning
@@ -26,6 +26,7 @@ nshtrainer/config.py,sha256=IXOAl_JWFNX9kPTo_iw4Nc3qXqkKrbA6-ZrvTAjqu6A,104
26
26
  nshtrainer/data/__init__.py,sha256=7mk1tr7SWUZ7ySbsf0y0ZPszk7u4QznPhQ-7wnpH9ec,149
27
27
  nshtrainer/data/balanced_batch_sampler.py,sha256=bcJBcQjh1hB1yKF_xSlT9AtEWv0BJjYc1CuH2BF-ea8,4392
28
28
  nshtrainer/data/transform.py,sha256=JeGxvytQly8hougrsdMmKG8gJ6qvFPDglJCO4Tp6STk,1795
29
+ nshtrainer/ll/__init__.py,sha256=1cccXGP085GSR5AYM4zVg4CgTso9rgzrPJ_mZz0RRJ0,1027
29
30
  nshtrainer/lr_scheduler/__init__.py,sha256=uEvgaFAs-4s_bAEMaildy0GT6OvgpgOEKTuzqutESHE,736
30
31
  nshtrainer/lr_scheduler/_base.py,sha256=7xOIuxQ86YHbFWG5a3gX46emQj1WN_LaY4-i0Q1TDBg,3659
31
32
  nshtrainer/lr_scheduler/linear_warmup_cosine.py,sha256=mn6cyizyI_stkXtg6zxIEGF9btIxMRWigUHUTlUYCSw,5221
@@ -46,7 +47,7 @@ nshtrainer/nn/module_dict.py,sha256=NOY0B6WDTnktyWH4GthsprMQo0bpehC-hCq9SfD8paE,
46
47
  nshtrainer/nn/module_list.py,sha256=fb2u5Rqdjff8Pekyr9hkCPkBorQ-fldzzFAjsgWAm30,1719
47
48
  nshtrainer/nn/nonlinearity.py,sha256=owtU4kh4G98psD0axOJWVfBhm-OtJVgFM-TXSHmbNPU,3625
48
49
  nshtrainer/optimizer.py,sha256=kuJEA1pvB3y1FcsfhAoOJujVqEZqFHlmYO8GW6JeA1g,1527
49
- nshtrainer/runner.py,sha256=zhNiDmv9R-oVmutQLrNUTDz9RLLAlHG6K0uYz77HkRM,3090
50
+ nshtrainer/runner.py,sha256=SfV3cWYQkRsMFvEx8Tk8JuNKrxkVqpy-SBV7n2ABZVw,3760
50
51
  nshtrainer/scripts/check_env.py,sha256=IMl6dSqsLYppI0XuCsVq8lK4bYqXwY9KHJkzsShz4Kg,806
51
52
  nshtrainer/scripts/find_packages.py,sha256=FbdlfmAefttFSMfaT0A46a-oHLP_ioaQKihwBfBeWeA,1467
52
53
  nshtrainer/trainer/__init__.py,sha256=P2rmr8oBVTHk-HJHYPcUwWqDEArMbPR4_rPpATbWK3E,40
@@ -58,6 +59,6 @@ nshtrainer/util/seed.py,sha256=HEXgVs-wldByahOysKwq7506OHxdYTEgmP-tDQVAEkQ,287
58
59
  nshtrainer/util/slurm.py,sha256=rofIU26z3SdL79SF45tNez6juou1cyDLz07oXEZb9Hg,1566
59
60
  nshtrainer/util/typed.py,sha256=NGuDkDzFlc1fAoaXjOFZVbmj0mRFjsQi1E_hPa7Bn5U,128
60
61
  nshtrainer/util/typing_utils.py,sha256=8ptjSSLZxlmy4FY6lzzkoGoF5fGNClo8-B_c0XHQaNU,385
61
- nshtrainer-0.4.1.dist-info/METADATA,sha256=HJFw7NgykuNISf63Lwa7mtnJf8Cpws2x4a_LirXSCnw,812
62
- nshtrainer-0.4.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
63
- nshtrainer-0.4.1.dist-info/RECORD,,
62
+ nshtrainer-0.5.0.dist-info/METADATA,sha256=CXlpxLR17WIzw9nUqjrp5L55GhKjHhPQ3mafnKK4YK0,812
63
+ nshtrainer-0.5.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
64
+ nshtrainer-0.5.0.dist-info/RECORD,,