kostyl-toolkit 0.1.0__tar.gz → 0.1.1__tar.gz

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.
Files changed (33) hide show
  1. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/PKG-INFO +1 -1
  2. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/configs/__init__.py +1 -1
  3. kostyl_toolkit-0.1.0/kostyl/ml_core/configs/config_mixins.py → kostyl_toolkit-0.1.1/kostyl/ml_core/configs/config_base.py +25 -10
  4. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/configs/hyperparams.py +2 -2
  5. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/configs/training_params.py +4 -4
  6. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/pyproject.toml +1 -1
  7. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/README.md +0 -0
  8. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/__init__.py +0 -0
  9. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/__init__.py +0 -0
  10. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/clearml/__init__.py +0 -0
  11. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/clearml/logging_utils.py +0 -0
  12. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/clearml/pulling_utils.py +0 -0
  13. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/dist_utils.py +0 -0
  14. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/__init__.py +0 -0
  15. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/callbacks/__init__.py +0 -0
  16. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/callbacks/checkpoint.py +0 -0
  17. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/callbacks/early_stopping.py +0 -0
  18. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/callbacks/registry_uploading.py +0 -0
  19. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/extenstions/__init__.py +0 -0
  20. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/extenstions/custom_module.py +0 -0
  21. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/extenstions/pretrained_model.py +0 -0
  22. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/loggers/__init__.py +0 -0
  23. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/loggers/tb_logger.py +0 -0
  24. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/steps_estimation.py +0 -0
  25. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/metrics_formatting.py +0 -0
  26. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/params_groups.py +0 -0
  27. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/schedulers/__init__.py +0 -0
  28. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/schedulers/base.py +0 -0
  29. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/schedulers/composite.py +0 -0
  30. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/schedulers/cosine.py +0 -0
  31. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/utils/__init__.py +0 -0
  32. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/utils/dict_manipulations.py +0 -0
  33. {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/utils/logging.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: kostyl-toolkit
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Kickass Orchestration System for Training, Yielding & Logging
5
5
  Requires-Dist: case-converter>=1.2.0
6
6
  Requires-Dist: clearml[s3]>=2.0.2
@@ -1,4 +1,4 @@
1
- from .config_mixins import ConfigLoadingMixin
1
+ from .config_base import ConfigLoadingMixin
2
2
  from .hyperparams import HyperparamsConfig
3
3
  from .hyperparams import Lr
4
4
  from .hyperparams import Optimizer
@@ -1,10 +1,11 @@
1
1
  from pathlib import Path
2
+ from typing import TypeVar
2
3
 
3
4
  import clearml
4
5
  import yaml
5
6
  from caseconverter import pascalcase
6
7
  from caseconverter import snakecase
7
- from pydantic import BaseModel
8
+ from pydantic import BaseModel as PydanticBaseModel
8
9
 
9
10
  from kostyl.utils import convert_to_flat_dict
10
11
  from kostyl.utils import flattened_dict_to_nested
@@ -26,18 +27,22 @@ def load_config(path: Path | str) -> dict:
26
27
  return config
27
28
 
28
29
 
29
- class ConfigLoadingMixin[TConfig: ConfigLoadingMixin](BaseModel):
30
+ TConfig = TypeVar("TConfig", bound=PydanticBaseModel)
31
+
32
+
33
+ class ConfigLoadingMixin:
30
34
  """Pydantic mixin class providing basic configuration loading functionality."""
31
35
 
32
36
  @classmethod
33
37
  def from_file(
34
- cls: type[TConfig],
38
+ cls: type[TConfig], # pyright: ignore[reportGeneralTypeIssues]
35
39
  path: str | Path,
36
40
  ) -> TConfig:
37
41
  """
38
42
  Create an instance of the class from a configuration file.
39
43
 
40
44
  Args:
45
+ cls_: The class type to instantiate.
41
46
  path (str | Path): Path to the configuration file.
42
47
 
43
48
  Returns:
@@ -50,13 +55,14 @@ class ConfigLoadingMixin[TConfig: ConfigLoadingMixin](BaseModel):
50
55
 
51
56
  @classmethod
52
57
  def from_dict(
53
- cls: type[TConfig],
58
+ cls: type[TConfig], # pyright: ignore[reportGeneralTypeIssues]
54
59
  state_dict: dict,
55
60
  ) -> TConfig:
56
61
  """
57
62
  Creates an instance from a dictionary.
58
63
 
59
64
  Args:
65
+ cls_: The class type to instantiate.
60
66
  state_dict (dict): A dictionary representing the state of the
61
67
  class that must be validated and used for initialization.
62
68
 
@@ -69,16 +75,19 @@ class ConfigLoadingMixin[TConfig: ConfigLoadingMixin](BaseModel):
69
75
  return instance
70
76
 
71
77
 
72
- class ClearMLConfigMixin[TConfig: ClearMLConfigMixin](ConfigLoadingMixin[TConfig]):
78
+ TModel = TypeVar("TModel", bound="ClearMLBaseModel")
79
+
80
+
81
+ class ClearMLConfigMixin(ConfigLoadingMixin):
73
82
  """Pydantic mixin class providing ClearML configuration loading and syncing functionality."""
74
83
 
75
84
  @classmethod
76
85
  def connect_as_file(
77
- cls: type[TConfig],
86
+ cls: type[TModel], # pyright: ignore[reportGeneralTypeIssues]
78
87
  task: clearml.Task,
79
88
  path: str | Path,
80
89
  alias: str | None = None,
81
- ) -> TConfig:
90
+ ) -> TModel:
82
91
  """
83
92
  Connects the configuration file to a ClearML task and creates an instance of the class from it.
84
93
 
@@ -113,11 +122,11 @@ class ClearMLConfigMixin[TConfig: ClearMLConfigMixin](ConfigLoadingMixin[TConfig
113
122
 
114
123
  @classmethod
115
124
  def connect_as_dict(
116
- cls: type[TConfig],
125
+ cls: type[TModel], # pyright: ignore[reportGeneralTypeIssues]
117
126
  task: clearml.Task,
118
127
  path: str | Path,
119
128
  alias: str | None = None,
120
- ) -> TConfig:
129
+ ) -> TModel:
121
130
  """
122
131
  Connects configuration from a file as a dictionary to a ClearML task and creates an instance of the class.
123
132
 
@@ -142,5 +151,11 @@ class ClearMLConfigMixin[TConfig: ClearMLConfigMixin](ConfigLoadingMixin[TConfig
142
151
  task.connect(flattened_config, name=pascalcase(name))
143
152
  config = flattened_dict_to_nested(flattened_config)
144
153
 
145
- model = cls.from_dict(config)
154
+ model = cls.from_dict(state_dict=config)
146
155
  return model
156
+
157
+
158
+ class ClearMLBaseModel(PydanticBaseModel, ClearMLConfigMixin):
159
+ """A Pydantic model class with ClearML configuration loading and syncing functionality."""
160
+
161
+ pass
@@ -4,7 +4,7 @@ from pydantic import model_validator
4
4
 
5
5
  from kostyl.utils.logging import setup_logger
6
6
 
7
- from .config_mixins import ClearMLConfigMixin
7
+ from .config_base import ClearMLBaseModel
8
8
 
9
9
 
10
10
  logger = setup_logger(fmt="only_message")
@@ -75,7 +75,7 @@ class WeightDecay(BaseModel):
75
75
  return self
76
76
 
77
77
 
78
- class HyperparamsConfig(ClearMLConfigMixin["HyperparamsConfig"]):
78
+ class HyperparamsConfig(ClearMLBaseModel):
79
79
  """Model training hyperparameters configuration."""
80
80
 
81
81
  grad_clip_val: float | None = Field(default=None, gt=0, validate_default=False)
@@ -5,8 +5,8 @@ from pydantic import Field
5
5
 
6
6
  from kostyl.utils.logging import setup_logger
7
7
 
8
- from .config_mixins import ClearMLConfigMixin
9
- from .config_mixins import ConfigLoadingMixin
8
+ from .config_base import ClearMLBaseModel
9
+ from .config_base import ConfigLoadingMixin
10
10
 
11
11
 
12
12
  logger = setup_logger(fmt="only_message")
@@ -91,7 +91,7 @@ class DataConfig(BaseModel):
91
91
  data_columns: list[str]
92
92
 
93
93
 
94
- class TrainingParams(ConfigLoadingMixin["TrainingParams"]):
94
+ class TrainingParams(ConfigLoadingMixin):
95
95
  """Training parameters configuration."""
96
96
 
97
97
  trainer: LightningTrainerParameters
@@ -102,7 +102,7 @@ class TrainingParams(ConfigLoadingMixin["TrainingParams"]):
102
102
 
103
103
  class ClearMLTrainingParameters(
104
104
  TrainingParams,
105
- ClearMLConfigMixin["ClearMLTrainingParameters"],
105
+ ClearMLBaseModel,
106
106
  ):
107
107
  """Training parameters configuration with ClearML features support (config syncing, model identifiers tracking and etc)."""
108
108
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "kostyl-toolkit"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  description = "Kickass Orchestration System for Training, Yielding & Logging "
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
File without changes