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.
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/PKG-INFO +1 -1
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/configs/__init__.py +1 -1
- 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
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/configs/hyperparams.py +2 -2
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/configs/training_params.py +4 -4
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/pyproject.toml +1 -1
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/README.md +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/__init__.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/__init__.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/clearml/__init__.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/clearml/logging_utils.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/clearml/pulling_utils.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/dist_utils.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/__init__.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/callbacks/__init__.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/callbacks/checkpoint.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/callbacks/early_stopping.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/callbacks/registry_uploading.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/extenstions/__init__.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/extenstions/custom_module.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/extenstions/pretrained_model.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/loggers/__init__.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/loggers/tb_logger.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/steps_estimation.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/metrics_formatting.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/params_groups.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/schedulers/__init__.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/schedulers/base.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/schedulers/composite.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/schedulers/cosine.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/utils/__init__.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/utils/dict_manipulations.py +0 -0
- {kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/utils/logging.py +0 -0
|
@@ -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
|
-
|
|
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
|
-
|
|
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[
|
|
86
|
+
cls: type[TModel], # pyright: ignore[reportGeneralTypeIssues]
|
|
78
87
|
task: clearml.Task,
|
|
79
88
|
path: str | Path,
|
|
80
89
|
alias: str | None = None,
|
|
81
|
-
) ->
|
|
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[
|
|
125
|
+
cls: type[TModel], # pyright: ignore[reportGeneralTypeIssues]
|
|
117
126
|
task: clearml.Task,
|
|
118
127
|
path: str | Path,
|
|
119
128
|
alias: str | None = None,
|
|
120
|
-
) ->
|
|
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 .
|
|
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(
|
|
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 .
|
|
9
|
-
from .
|
|
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
|
|
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
|
-
|
|
105
|
+
ClearMLBaseModel,
|
|
106
106
|
):
|
|
107
107
|
"""Training parameters configuration with ClearML features support (config syncing, model identifiers tracking and etc)."""
|
|
108
108
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/callbacks/__init__.py
RENAMED
|
File without changes
|
{kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/callbacks/checkpoint.py
RENAMED
|
File without changes
|
{kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/callbacks/early_stopping.py
RENAMED
|
File without changes
|
|
File without changes
|
{kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/extenstions/__init__.py
RENAMED
|
File without changes
|
{kostyl_toolkit-0.1.0 → kostyl_toolkit-0.1.1}/kostyl/ml_core/lightning/extenstions/custom_module.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|