nshtrainer 0.6.2__py3-none-any.whl → 0.8.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.
nshtrainer/ll/__init__.py CHANGED
@@ -1,46 +1,58 @@
1
- import importlib
2
- import sys
3
- from types import ModuleType
4
- from typing import TYPE_CHECKING
5
-
6
- # The name of your new package
7
- NEW_PACKAGE = "nshtrainer"
8
-
9
- # Import the new package
10
- new_package = importlib.import_module(NEW_PACKAGE)
11
-
12
-
13
- # Create a custom module class that inherits from ModuleType
14
- class ProxyModule(ModuleType):
15
- def __getattr__(self, name):
16
- return getattr(new_package, name)
17
-
18
- def __dir__(self):
19
- return dir(new_package)
20
-
21
-
22
- # Create a new module instance
23
- old_module = ProxyModule(__name__)
24
-
25
- # Copy attributes from new_package to old_module
26
- for attr in dir(new_package):
27
- if not attr.startswith("__"):
28
- setattr(old_module, attr, getattr(new_package, attr))
29
-
30
- # Replace the module in sys.modules
31
- sys.modules[__name__] = old_module
32
-
33
-
34
- # Handle submodule imports
35
- class SubmoduleProxy:
36
- def __getattr__(self, name):
37
- return importlib.import_module(f"{NEW_PACKAGE}.{name}")
38
-
39
-
40
- # Add submodule handling to the proxy module
41
- old_module.__class__ = type(
42
- "ProxyModuleWithSubmodules", (ProxyModule, SubmoduleProxy), {}
1
+ from . import _experimental as _experimental
2
+ from . import actsave as actsave
3
+ from . import callbacks as callbacks
4
+ from . import lr_scheduler as lr_scheduler
5
+ from . import model as model
6
+ from . import nn as nn
7
+ from . import optimizer as optimizer
8
+ from . import snapshot as snapshot
9
+ from . import typecheck as typecheck
10
+ from .actsave import ActLoad as ActLoad
11
+ from .actsave import ActSave as ActSave
12
+ from .config import MISSING as MISSING
13
+ from .config import AllowMissing as AllowMissing
14
+ from .config import Field as Field
15
+ from .config import MissingField as MissingField
16
+ from .config import PrivateAttr as PrivateAttr
17
+ from .config import TypedConfig as TypedConfig
18
+ from .data import dataset_transform as dataset_transform
19
+ from .log import init_python_logging as init_python_logging
20
+ from .log import lovely as lovely
21
+ from .log import pretty as pretty
22
+ from .lr_scheduler import LRSchedulerConfig as LRSchedulerConfig
23
+ from .model import ActSaveConfig as ActSaveConfig
24
+ from .model import Base as Base
25
+ from .model import BaseConfig as BaseConfig
26
+ from .model import BaseLoggerConfig as BaseLoggerConfig
27
+ from .model import BaseProfilerConfig as BaseProfilerConfig
28
+ from .model import CheckpointLoadingConfig as CheckpointLoadingConfig
29
+ from .model import CheckpointSavingConfig as CheckpointSavingConfig
30
+ from .model import ConfigList as ConfigList
31
+ from .model import DirectoryConfig as DirectoryConfig
32
+ from .model import (
33
+ EnvironmentClassInformationConfig as EnvironmentClassInformationConfig,
43
34
  )
44
-
45
- if TYPE_CHECKING:
46
- from nshtrainer import * # noqa: F401, F403
35
+ from .model import EnvironmentConfig as EnvironmentConfig
36
+ from .model import (
37
+ EnvironmentLinuxEnvironmentConfig as EnvironmentLinuxEnvironmentConfig,
38
+ )
39
+ from .model import (
40
+ EnvironmentSLURMInformationConfig as EnvironmentSLURMInformationConfig,
41
+ )
42
+ from .model import GradientClippingConfig as GradientClippingConfig
43
+ from .model import LightningModuleBase as LightningModuleBase
44
+ from .model import LoggingConfig as LoggingConfig
45
+ from .model import MetricConfig as MetricConfig
46
+ from .model import OptimizationConfig as OptimizationConfig
47
+ from .model import PrimaryMetricConfig as PrimaryMetricConfig
48
+ from .model import ReproducibilityConfig as ReproducibilityConfig
49
+ from .model import SanityCheckingConfig as SanityCheckingConfig
50
+ from .model import TrainerConfig as TrainerConfig
51
+ from .model import WandbWatchConfig as WandbWatchConfig
52
+ from .nn import TypedModuleDict as TypedModuleDict
53
+ from .nn import TypedModuleList as TypedModuleList
54
+ from .optimizer import OptimizerConfig as OptimizerConfig
55
+ from .runner import Runner as Runner
56
+ from .runner import SnapshotConfig as SnapshotConfig
57
+ from .snoop import snoop as snoop
58
+ from .trainer import Trainer as Trainer
@@ -0,0 +1,3 @@
1
+ from nshutils.actsave import * # type: ignore # noqa: F403
2
+
3
+ from nshtrainer.actsave import * # type: ignore # noqa: F403
@@ -0,0 +1 @@
1
+ from nshtrainer.callbacks import * # noqa: F403
@@ -0,0 +1,4 @@
1
+ from nshconfig import * # type: ignore # noqa: F403
2
+ from nshconfig import Config as TypedConfig # type: ignore # noqa: F401
3
+
4
+ _ = TypedConfig
nshtrainer/ll/data.py ADDED
@@ -0,0 +1 @@
1
+ from nshtrainer.data import * # noqa: F403
nshtrainer/ll/log.py ADDED
@@ -0,0 +1,3 @@
1
+ from nshutils import init_python_logging as init_python_logging
2
+ from nshutils import lovely as lovely
3
+ from nshutils import pretty as pretty
@@ -0,0 +1 @@
1
+ from nshtrainer.lr_scheduler import * # noqa: F403
nshtrainer/ll/model.py ADDED
@@ -0,0 +1 @@
1
+ from nshtrainer.model import * # noqa: F403
nshtrainer/ll/nn.py ADDED
@@ -0,0 +1 @@
1
+ from nshtrainer.nn import * # noqa: F403
@@ -0,0 +1 @@
1
+ from nshtrainer.optimizer import * # noqa: F403
@@ -0,0 +1,3 @@
1
+ from nshrunner import SnapshotConfig as SnapshotConfig
2
+
3
+ from nshtrainer.runner import * # type: ignore # noqa: F403
nshtrainer/ll/snoop.py ADDED
@@ -0,0 +1 @@
1
+ from nshutils import snoop as snoop
@@ -0,0 +1 @@
1
+ from nshtrainer.trainer import * # noqa: F403
nshtrainer/ll/util.py ADDED
@@ -0,0 +1 @@
1
+ from nshtrainer.util import * # noqa: F403
@@ -38,7 +38,7 @@ class ReduceLROnPlateauConfig(LRSchedulerConfigBase):
38
38
  threshold: float = 1.0e-4
39
39
  r"""Threshold for measuring the new optimum, to only focus on significant changes."""
40
40
 
41
- threshold_mode: str = "rel"
41
+ threshold_mode: Literal["rel", "abs"] = "rel"
42
42
  r"""One of `rel`, `abs`. In `rel` mode, dynamic_threshold = best * (1 + threshold) in 'max' mode or best * (1 - threshold) in `min` mode. In `abs` mode, dynamic_threshold = best + threshold in `max` mode or best - threshold in `min` mode. Default: 'rel'."""
43
43
 
44
44
  @override
nshtrainer/model/base.py CHANGED
@@ -133,7 +133,7 @@ def _psutil():
133
133
  return psutil
134
134
 
135
135
 
136
- def _try_get(fn: Callable[[], T]) -> T | None:
136
+ def _try_get(fn: Callable[[], T | None]) -> T | None:
137
137
  try:
138
138
  return fn()
139
139
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nshtrainer
3
- Version: 0.6.2
3
+ Version: 0.8.0
4
4
  Summary:
5
5
  Author: Nima Shoghi
6
6
  Author-email: nimashoghi@gmail.com
@@ -10,14 +10,11 @@ Classifier: Programming Language :: Python :: 3.10
10
10
  Classifier: Programming Language :: Python :: 3.11
11
11
  Classifier: Programming Language :: Python :: 3.12
12
12
  Requires-Dist: lightning
13
- Requires-Dist: lovely-numpy (>=0.2.13,<0.3.0)
14
- Requires-Dist: lovely-tensors (>=0.1.16,<0.2.0)
15
- Requires-Dist: nshconfig (>=0,<1)
16
- Requires-Dist: nshrunner (>=0,<1)
17
- Requires-Dist: nshutils (>=0,<1)
13
+ Requires-Dist: nshconfig
14
+ Requires-Dist: nshrunner
15
+ Requires-Dist: nshutils
18
16
  Requires-Dist: numpy
19
17
  Requires-Dist: pytorch-lightning
20
- Requires-Dist: rich
21
18
  Requires-Dist: torch
22
19
  Requires-Dist: torchmetrics
23
20
  Requires-Dist: typing-extensions
@@ -26,13 +26,27 @@ 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=u3wEyfc8kIsdRwZ8jpmywkEykHX4iIa-xA4we9GSuYE,1128
29
+ nshtrainer/ll/__init__.py,sha256=qraZm_bAvoLR69w5iiAic9-TT4sR0g_iKnttiXbb5y0,2658
30
+ nshtrainer/ll/actsave.py,sha256=QJ7yJIqvabpZzumX7PLPzkh6dfqY-zxiEdzv48VtZEY,123
31
+ nshtrainer/ll/callbacks.py,sha256=AxyUmc8aGRSjx6WwwgXYCmdJ73rwLuEAEH0AGRosojQ,49
32
+ nshtrainer/ll/config.py,sha256=fKumJf42HY2FITX1QUM1OTXkYD6U2np2ciyd4PFRPZ8,145
33
+ nshtrainer/ll/data.py,sha256=zRG0FRje-jtSHximVzkHIHzpwsyQxpHCoACFihNKLPM,44
34
+ nshtrainer/ll/log.py,sha256=d4BB3TyM8imK65EXOiOeUTF0zFM1ropbe7Vq3DeB0xU,140
35
+ nshtrainer/ll/lr_scheduler.py,sha256=7xjhN6L69BCUzFhcy33NtMtPuCzHiB611zVWFg92lQ0,52
36
+ nshtrainer/ll/model.py,sha256=6I9gQjEFT2Veer-UmcPy05Pt3mnvaxYX1b3sOdaF96A,45
37
+ nshtrainer/ll/nn.py,sha256=8qiRDFwojIxkB7-LtNWk4mLL2tJbaskHYofDsOIHiNg,42
38
+ nshtrainer/ll/optimizer.py,sha256=3T-VZtT73jVvwCNJGDjgGEbzs-1LFTzMQH-SB_58mSo,49
39
+ nshtrainer/ll/runner.py,sha256=B0m5VEhNKIjF1aFmqPkonkQxDoRL2jeHZGsV3zwhSVE,117
40
+ nshtrainer/ll/snoop.py,sha256=hG9VCdm8mIZytHLZgUKRSoWqg55rVvUpBAH-OSiwgvI,36
41
+ nshtrainer/ll/trainer.py,sha256=hkn2xPtrSPQ7LqQhbyAKuMfNyHdhqB9bDPvgRCK8oJM,47
42
+ nshtrainer/ll/typecheck.py,sha256=ryV1Tzcf7hJ4I19H1oQVkikU9spmRk8jyIKQZ5UF7pQ,62
43
+ nshtrainer/ll/util.py,sha256=PQGu5Ff1raizxjXdm2rFFu4Mo816dBIYmItjkJX1_qk,44
30
44
  nshtrainer/lr_scheduler/__init__.py,sha256=uEvgaFAs-4s_bAEMaildy0GT6OvgpgOEKTuzqutESHE,736
31
45
  nshtrainer/lr_scheduler/_base.py,sha256=7xOIuxQ86YHbFWG5a3gX46emQj1WN_LaY4-i0Q1TDBg,3659
32
46
  nshtrainer/lr_scheduler/linear_warmup_cosine.py,sha256=mn6cyizyI_stkXtg6zxIEGF9btIxMRWigUHUTlUYCSw,5221
33
- nshtrainer/lr_scheduler/reduce_lr_on_plateau.py,sha256=2ZdlV0RUMwg2DClzqYHr8_EKT1jZBUlSD39e-XlCsC4,2764
47
+ nshtrainer/lr_scheduler/reduce_lr_on_plateau.py,sha256=h76oTHYpMxauV_l6lviya5DW-WKArwxxf7ZQizhmbCw,2782
34
48
  nshtrainer/model/__init__.py,sha256=y32Hla-5whpzLL2BtCJpBakSp8o-1nQbpO0j_-xq_Po,1864
35
- nshtrainer/model/base.py,sha256=EMkOtp4YWGPHM0HPSTLbx75T9vlYmXO4XyD725xU70w,21453
49
+ nshtrainer/model/base.py,sha256=k2Qk_rH4FsBOib2PISXnG97SBlgeD1w_jw02NE4zEQI,21460
36
50
  nshtrainer/model/config.py,sha256=6lATW6-Z1SIDgQ1IWrGBVQKTr8DhL5b_rFbJHQz0d5o,66796
37
51
  nshtrainer/model/modules/callback.py,sha256=JF59U9-CjJsAIspEhTJbVaGN0wGctZG7UquE3IS7R8A,6408
38
52
  nshtrainer/model/modules/debug.py,sha256=DTVty8cKnzj1GCULRyGx_sWTTsq9NLi30dzqjRTnuCU,1127
@@ -53,12 +67,11 @@ nshtrainer/scripts/find_packages.py,sha256=FbdlfmAefttFSMfaT0A46a-oHLP_ioaQKihwB
53
67
  nshtrainer/trainer/__init__.py,sha256=P2rmr8oBVTHk-HJHYPcUwWqDEArMbPR4_rPpATbWK3E,40
54
68
  nshtrainer/trainer/signal_connector.py,sha256=QAoPM_C5JJOVQebcrJOimUUD3GHyoeZUqCEAvzZlT4U,8710
55
69
  nshtrainer/trainer/trainer.py,sha256=eYEYfY9v70MuorHcSf8nqM7f2CkmUHhpPcjCk4FJD7k,14034
56
- nshtrainer/typecheck.py,sha256=ryV1Tzcf7hJ4I19H1oQVkikU9spmRk8jyIKQZ5UF7pQ,62
57
70
  nshtrainer/util/environment.py,sha256=_SEtiQ_s5bL5pllUlf96AOUv15kNvCPvocVC13S7mIk,4166
58
71
  nshtrainer/util/seed.py,sha256=HEXgVs-wldByahOysKwq7506OHxdYTEgmP-tDQVAEkQ,287
59
72
  nshtrainer/util/slurm.py,sha256=rofIU26z3SdL79SF45tNez6juou1cyDLz07oXEZb9Hg,1566
60
73
  nshtrainer/util/typed.py,sha256=NGuDkDzFlc1fAoaXjOFZVbmj0mRFjsQi1E_hPa7Bn5U,128
61
74
  nshtrainer/util/typing_utils.py,sha256=8ptjSSLZxlmy4FY6lzzkoGoF5fGNClo8-B_c0XHQaNU,385
62
- nshtrainer-0.6.2.dist-info/METADATA,sha256=TTXxrNVSf7oLTDywORfH9G0gH8oDHsNTuYsucQw5BWE,788
63
- nshtrainer-0.6.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
64
- nshtrainer-0.6.2.dist-info/RECORD,,
75
+ nshtrainer-0.8.0.dist-info/METADATA,sha256=TDEXjHhjXVtEmL3ScRK77EXZ4-jNqYlYJtLvccK4SLw,647
76
+ nshtrainer-0.8.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
77
+ nshtrainer-0.8.0.dist-info/RECORD,,
File without changes