kostyl-toolkit 0.1.11__tar.gz → 0.1.13__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 (36) hide show
  1. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/PKG-INFO +1 -1
  2. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/clearml/pulling_utils.py +1 -1
  3. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/configs/__init__.py +0 -2
  4. kostyl_toolkit-0.1.11/kostyl/ml/clearml/config_mixin.py → kostyl_toolkit-0.1.13/kostyl/ml/configs/base_model.py +63 -11
  5. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/configs/hyperparams.py +3 -2
  6. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/configs/training_settings.py +0 -11
  7. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/pyproject.toml +1 -1
  8. kostyl_toolkit-0.1.11/kostyl/ml/configs/base_model.py +0 -60
  9. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/README.md +0 -0
  10. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/__init__.py +0 -0
  11. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/__init__.py +0 -0
  12. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/clearml/__init__.py +0 -0
  13. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/clearml/dataset_utils.py +0 -0
  14. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/clearml/logging_utils.py +0 -0
  15. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/dist_utils.py +0 -0
  16. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/lightning/__init__.py +0 -0
  17. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/lightning/callbacks/__init__.py +0 -0
  18. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/lightning/callbacks/checkpoint.py +0 -0
  19. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/lightning/callbacks/early_stopping.py +0 -0
  20. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/lightning/callbacks/registry_uploading.py +0 -0
  21. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/lightning/extenstions/__init__.py +0 -0
  22. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/lightning/extenstions/custom_module.py +0 -0
  23. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/lightning/extenstions/pretrained_model.py +0 -0
  24. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/lightning/loggers/__init__.py +0 -0
  25. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/lightning/loggers/tb_logger.py +0 -0
  26. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/lightning/steps_estimation.py +0 -0
  27. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/metrics_formatting.py +0 -0
  28. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/params_groups.py +0 -0
  29. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/schedulers/__init__.py +0 -0
  30. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/schedulers/base.py +0 -0
  31. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/schedulers/composite.py +0 -0
  32. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/ml/schedulers/cosine.py +0 -0
  33. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/utils/__init__.py +0 -0
  34. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/utils/dict_manipulations.py +0 -0
  35. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/kostyl/utils/fs.py +0 -0
  36. {kostyl_toolkit-0.1.11 → kostyl_toolkit-0.1.13}/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.11
3
+ Version: 0.1.13
4
4
  Summary: Kickass Orchestration System for Training, Yielding & Logging
5
5
  Requires-Dist: case-converter>=1.2.0
6
6
  Requires-Dist: loguru>=0.7.3
@@ -1,9 +1,9 @@
1
1
  from pathlib import Path
2
+ from typing import Any
2
3
  from typing import cast
3
4
 
4
5
  from clearml import InputModel
5
6
  from clearml import Task
6
- from transformers import Any
7
7
  from transformers import AutoModel
8
8
  from transformers import AutoTokenizer
9
9
  from transformers import PreTrainedModel
@@ -4,7 +4,6 @@ from .hyperparams import Lr
4
4
  from .hyperparams import Optimizer
5
5
  from .hyperparams import WeightDecay
6
6
  from .training_settings import CheckpointConfig
7
- from .training_settings import ClearMLTrainingSettings
8
7
  from .training_settings import DataConfig
9
8
  from .training_settings import DDPStrategyConfig
10
9
  from .training_settings import EarlyStoppingConfig
@@ -16,7 +15,6 @@ from .training_settings import TrainingSettings
16
15
 
17
16
  __all__ = [
18
17
  "CheckpointConfig",
19
- "ClearMLTrainingSettings",
20
18
  "DDPStrategyConfig",
21
19
  "DataConfig",
22
20
  "EarlyStoppingConfig",
@@ -1,29 +1,75 @@
1
1
  from pathlib import Path
2
+ from typing import Self
2
3
  from typing import TypeVar
3
4
 
4
- import clearml
5
5
  from caseconverter import pascalcase
6
6
  from caseconverter import snakecase
7
+ from clearml import Task
8
+ from pydantic import BaseModel as PydanticBaseModel
7
9
 
8
- from kostyl.ml.configs.base_model import KostylBaseModel
9
10
  from kostyl.utils.dict_manipulations import convert_to_flat_dict
10
11
  from kostyl.utils.dict_manipulations import flattened_dict_to_nested
11
12
  from kostyl.utils.fs import load_config
12
13
 
13
14
 
14
- TModel = TypeVar("TModel", bound="KostylBaseModel")
15
+ TConfig = TypeVar("TConfig", bound=PydanticBaseModel)
15
16
 
16
17
 
17
- class ClearMLConfigMixin:
18
- """Pydantic mixin class providing ClearML configuration loading and syncing functionality."""
18
+ class BaseModelWithConfigLoading(PydanticBaseModel):
19
+ """Pydantic class providing basic configuration loading functionality."""
20
+
21
+ @classmethod
22
+ def from_file(
23
+ cls: type[Self], # pyright: ignore
24
+ path: str | Path,
25
+ ) -> Self:
26
+ """
27
+ Create an instance of the class from a configuration file.
28
+
29
+ Args:
30
+ cls_: The class type to instantiate.
31
+ path (str | Path): Path to the configuration file.
32
+
33
+ Returns:
34
+ An instance of the class created from the configuration file.
35
+
36
+ """
37
+ config = load_config(path)
38
+ instance = cls.model_validate(config)
39
+ return instance
40
+
41
+ @classmethod
42
+ def from_dict(
43
+ cls: type[Self], # pyright: ignore
44
+ state_dict: dict,
45
+ ) -> Self:
46
+ """
47
+ Creates an instance from a dictionary.
48
+
49
+ Args:
50
+ cls_: The class type to instantiate.
51
+ state_dict (dict): A dictionary representing the state of the
52
+ class that must be validated and used for initialization.
53
+
54
+ Returns:
55
+ An initialized instance of the class based on the
56
+ provided state dictionary.
57
+
58
+ """
59
+ instance = cls.model_validate(state_dict)
60
+ return instance
61
+
62
+
63
+ class BaseModelWithClearmlSyncing(BaseModelWithConfigLoading):
64
+ """Pydantic class providing ClearML configuration loading and syncing functionality."""
19
65
 
20
66
  @classmethod
21
67
  def connect_as_file(
22
- cls: type[TModel], # pyright: ignore
23
- task: clearml.Task,
68
+ cls: type[Self], # pyright: ignore
69
+ task: Task,
24
70
  path: str | Path,
25
71
  alias: str | None = None,
26
- ) -> TModel:
72
+ ) -> Self:
27
73
  """
28
74
  Connects the configuration file to a ClearML task and creates an instance of the class from it.
29
75
 
@@ -58,11 +104,11 @@ class ClearMLConfigMixin:
58
104
 
59
105
  @classmethod
60
106
  def connect_as_dict(
61
- cls: type[TModel], # pyright: ignore
62
- task: clearml.Task,
107
+ cls: type[Self], # pyright: ignore
108
+ task: Task,
63
109
  path: str | Path,
64
110
  alias: str | None = None,
65
- ) -> TModel:
111
+ ) -> Self:
66
112
  """
67
113
  Connects configuration from a file as a dictionary to a ClearML task and creates an instance of the class.
68
114
 
@@ -89,3 +135,9 @@ class ClearMLConfigMixin:
89
135
 
90
136
  model = cls.from_dict(state_dict=config)
91
137
  return model
138
+
139
+
140
+ class KostylBaseModel(BaseModelWithClearmlSyncing):
141
+ """A Pydantic model class with basic configuration loading functionality."""
142
+
143
+ pass
@@ -2,9 +2,10 @@ from pydantic import BaseModel
2
2
  from pydantic import Field
3
3
  from pydantic import model_validator
4
4
 
5
- from kostyl.ml.clearml.config_mixin import ClearMLConfigMixin
6
5
  from kostyl.utils.logging import setup_logger
7
6
 
7
+ from .base_model import KostylBaseModel
8
+
8
9
 
9
10
  logger = setup_logger(fmt="only_message")
10
11
 
@@ -74,7 +75,7 @@ class WeightDecay(BaseModel):
74
75
  return self
75
76
 
76
77
 
77
- class HyperparamsConfig(BaseModel, ClearMLConfigMixin):
78
+ class HyperparamsConfig(KostylBaseModel):
78
79
  """Model training hyperparameters configuration."""
79
80
 
80
81
  grad_clip_val: float | None = Field(default=None, gt=0, validate_default=False)
@@ -3,7 +3,6 @@ from typing import Literal
3
3
  from pydantic import BaseModel
4
4
  from pydantic import Field
5
5
 
6
- from kostyl.ml.clearml.config_mixin import ClearMLConfigMixin
7
6
  from kostyl.utils.logging import setup_logger
8
7
 
9
8
  from .base_model import KostylBaseModel
@@ -103,13 +102,3 @@ class TrainingSettings(KostylBaseModel):
103
102
  early_stopping: EarlyStoppingConfig | None = None
104
103
  checkpoint: CheckpointConfig
105
104
  data: DataConfig
106
-
107
-
108
- class ClearMLTrainingSettings(
109
- TrainingSettings,
110
- ClearMLConfigMixin,
111
- ):
112
- """Training parameters configuration with ClearML features support (config syncing, model identifiers tracking and etc)."""
113
-
114
- model_id: str
115
- tokenizer_id: str
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "kostyl-toolkit"
3
- version = "0.1.11"
3
+ version = "0.1.13"
4
4
  description = "Kickass Orchestration System for Training, Yielding & Logging "
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -1,60 +0,0 @@
1
- from pathlib import Path
2
- from typing import TypeVar
3
-
4
- from pydantic import BaseModel as PydanticBaseModel
5
-
6
- from kostyl.utils.fs import load_config
7
-
8
-
9
- TConfig = TypeVar("TConfig", bound=PydanticBaseModel)
10
-
11
-
12
- class ConfigLoadingMixin:
13
- """Pydantic mixin class providing basic configuration loading functionality."""
14
-
15
- @classmethod
16
- def from_file(
17
- cls: type[TConfig], # pyright: ignore
18
- path: str | Path,
19
- ) -> TConfig:
20
- """
21
- Create an instance of the class from a configuration file.
22
-
23
- Args:
24
- cls_: The class type to instantiate.
25
- path (str | Path): Path to the configuration file.
26
-
27
- Returns:
28
- An instance of the class created from the configuration file.
29
-
30
- """
31
- config = load_config(path)
32
- instance = cls.model_validate(config)
33
- return instance
34
-
35
- @classmethod
36
- def from_dict(
37
- cls: type[TConfig], # pyright: ignore
38
- state_dict: dict,
39
- ) -> TConfig:
40
- """
41
- Creates an instance from a dictionary.
42
-
43
- Args:
44
- cls_: The class type to instantiate.
45
- state_dict (dict): A dictionary representing the state of the
46
- class that must be validated and used for initialization.
47
-
48
- Returns:
49
- An initialized instance of the class based on the
50
- provided state dictionary.
51
-
52
- """
53
- instance = cls.model_validate(state_dict)
54
- return instance
55
-
56
-
57
- class KostylBaseModel(PydanticBaseModel, ConfigLoadingMixin):
58
- """A Pydantic model class with basic configuration loading functionality."""
59
-
60
- pass