kostyl-toolkit 0.1.6__py3-none-any.whl → 0.1.8__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.
- kostyl/ml_core/clearml/config_mixin.py +3 -10
- kostyl/ml_core/clearml/dataset_utils.py +4 -7
- kostyl/ml_core/configs/__init__.py +14 -12
- kostyl/ml_core/configs/{base.py → base_model.py} +7 -1
- kostyl/ml_core/configs/{training_params.py → training_settings.py} +5 -4
- kostyl/ml_core/lightning/extenstions/pretrained_model.py +1 -1
- {kostyl_toolkit-0.1.6.dist-info → kostyl_toolkit-0.1.8.dist-info}/METADATA +1 -1
- {kostyl_toolkit-0.1.6.dist-info → kostyl_toolkit-0.1.8.dist-info}/RECORD +9 -9
- {kostyl_toolkit-0.1.6.dist-info → kostyl_toolkit-0.1.8.dist-info}/WHEEL +1 -1
|
@@ -4,18 +4,17 @@ from typing import TypeVar
|
|
|
4
4
|
import clearml
|
|
5
5
|
from caseconverter import pascalcase
|
|
6
6
|
from caseconverter import snakecase
|
|
7
|
-
from pydantic import BaseModel as PydanticBaseModel
|
|
8
7
|
|
|
9
|
-
from kostyl.ml_core.configs.
|
|
8
|
+
from kostyl.ml_core.configs.base_model import KostylBaseModel
|
|
10
9
|
from kostyl.utils.dict_manipulations import convert_to_flat_dict
|
|
11
10
|
from kostyl.utils.dict_manipulations import flattened_dict_to_nested
|
|
12
11
|
from kostyl.utils.fs import load_config
|
|
13
12
|
|
|
14
13
|
|
|
15
|
-
TModel = TypeVar("TModel", bound="
|
|
14
|
+
TModel = TypeVar("TModel", bound="KostylBaseModel")
|
|
16
15
|
|
|
17
16
|
|
|
18
|
-
class ClearMLConfigMixin
|
|
17
|
+
class ClearMLConfigMixin:
|
|
19
18
|
"""Pydantic mixin class providing ClearML configuration loading and syncing functionality."""
|
|
20
19
|
|
|
21
20
|
@classmethod
|
|
@@ -90,9 +89,3 @@ class ClearMLConfigMixin(ConfigLoadingMixin):
|
|
|
90
89
|
|
|
91
90
|
model = cls.from_dict(state_dict=config)
|
|
92
91
|
return model
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
class _ClearMLBaseModel(PydanticBaseModel, ClearMLConfigMixin):
|
|
96
|
-
"""A Pydantic model class with ClearML configuration loading and syncing functionality."""
|
|
97
|
-
|
|
98
|
-
pass
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from collections.abc import Collection
|
|
1
2
|
from concurrent.futures import ThreadPoolExecutor
|
|
2
3
|
from concurrent.futures import as_completed
|
|
3
4
|
from pathlib import Path
|
|
@@ -26,20 +27,16 @@ def collect_clearml_datasets(
|
|
|
26
27
|
return datasets_list
|
|
27
28
|
|
|
28
29
|
|
|
29
|
-
def download_clearml_datasets(
|
|
30
|
+
def download_clearml_datasets(datasets: Collection[ClearMLDataset]) -> None:
|
|
30
31
|
"""
|
|
31
32
|
Download all ClearML datasets in parallel.
|
|
32
33
|
|
|
33
34
|
Args:
|
|
34
|
-
|
|
35
|
-
`ClearMLDataset` instances whose contents must be downloaded
|
|
36
|
-
locally.
|
|
35
|
+
datasets: Collection of initialized `ClearMLDataset` instances to download.
|
|
37
36
|
|
|
38
37
|
"""
|
|
39
38
|
with ThreadPoolExecutor() as executor:
|
|
40
|
-
futures = [
|
|
41
|
-
executor.submit(ds.get_local_copy) for ds in datasets_mapping.values()
|
|
42
|
-
]
|
|
39
|
+
futures = [executor.submit(ds.get_local_copy) for ds in datasets]
|
|
43
40
|
for future in as_completed(futures):
|
|
44
41
|
future.result()
|
|
45
42
|
return
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .base_model import KostylBaseModel
|
|
2
2
|
from .hyperparams import HyperparamsConfig
|
|
3
3
|
from .hyperparams import Lr
|
|
4
4
|
from .hyperparams import Optimizer
|
|
5
5
|
from .hyperparams import WeightDecay
|
|
6
|
-
from .
|
|
7
|
-
from .
|
|
8
|
-
from .
|
|
9
|
-
from .
|
|
10
|
-
from .
|
|
11
|
-
from .
|
|
12
|
-
from .
|
|
13
|
-
from .
|
|
6
|
+
from .training_settings import CheckpointConfig
|
|
7
|
+
from .training_settings import ClearMLTrainingSettings
|
|
8
|
+
from .training_settings import DataConfig
|
|
9
|
+
from .training_settings import DDPStrategyConfig
|
|
10
|
+
from .training_settings import EarlyStoppingConfig
|
|
11
|
+
from .training_settings import FSDP1StrategyConfig
|
|
12
|
+
from .training_settings import LightningTrainerParameters
|
|
13
|
+
from .training_settings import SingleDeviceStrategyConfig
|
|
14
|
+
from .training_settings import TrainingSettings
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
__all__ = [
|
|
17
18
|
"CheckpointConfig",
|
|
18
|
-
"
|
|
19
|
-
"ConfigLoadingMixin",
|
|
19
|
+
"ClearMLTrainingSettings",
|
|
20
20
|
"DDPStrategyConfig",
|
|
21
21
|
"DataConfig",
|
|
22
22
|
"EarlyStoppingConfig",
|
|
23
23
|
"FSDP1StrategyConfig",
|
|
24
24
|
"HyperparamsConfig",
|
|
25
|
+
"KostylBaseModel",
|
|
26
|
+
"LightningTrainerParameters",
|
|
25
27
|
"Lr",
|
|
26
28
|
"Optimizer",
|
|
27
29
|
"SingleDeviceStrategyConfig",
|
|
28
|
-
"
|
|
30
|
+
"TrainingSettings",
|
|
29
31
|
"WeightDecay",
|
|
30
32
|
]
|
|
@@ -9,7 +9,7 @@ from kostyl.utils.fs import load_config
|
|
|
9
9
|
TConfig = TypeVar("TConfig", bound=PydanticBaseModel)
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class
|
|
12
|
+
class _ConfigLoadingMixin:
|
|
13
13
|
"""Pydantic mixin class providing basic configuration loading functionality."""
|
|
14
14
|
|
|
15
15
|
@classmethod
|
|
@@ -52,3 +52,9 @@ class ConfigLoadingMixin:
|
|
|
52
52
|
"""
|
|
53
53
|
instance = cls.model_validate(state_dict)
|
|
54
54
|
return instance
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class KostylBaseModel(PydanticBaseModel, _ConfigLoadingMixin):
|
|
58
|
+
"""A Pydantic model class with basic configuration loading functionality."""
|
|
59
|
+
|
|
60
|
+
pass
|
|
@@ -6,7 +6,7 @@ from pydantic import Field
|
|
|
6
6
|
from kostyl.ml_core.clearml.config_mixin import ClearMLConfigMixin
|
|
7
7
|
from kostyl.utils.logging import setup_logger
|
|
8
8
|
|
|
9
|
-
from .
|
|
9
|
+
from .base_model import KostylBaseModel
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
logger = setup_logger(fmt="only_message")
|
|
@@ -49,6 +49,7 @@ class DDPStrategyConfig(BaseModel):
|
|
|
49
49
|
"""Distributed Data Parallel (DDP) strategy configuration."""
|
|
50
50
|
|
|
51
51
|
type: Literal["ddp"]
|
|
52
|
+
find_unused_parameters: bool = False
|
|
52
53
|
|
|
53
54
|
|
|
54
55
|
class LightningTrainerParameters(BaseModel):
|
|
@@ -91,7 +92,7 @@ class DataConfig(BaseModel):
|
|
|
91
92
|
data_columns: list[str]
|
|
92
93
|
|
|
93
94
|
|
|
94
|
-
class
|
|
95
|
+
class TrainingSettings(KostylBaseModel):
|
|
95
96
|
"""Training parameters configuration."""
|
|
96
97
|
|
|
97
98
|
trainer: LightningTrainerParameters
|
|
@@ -100,9 +101,9 @@ class TrainingParams(BaseModel, ConfigLoadingMixin):
|
|
|
100
101
|
data: DataConfig
|
|
101
102
|
|
|
102
103
|
|
|
103
|
-
class
|
|
104
|
+
class ClearMLTrainingSettings(
|
|
105
|
+
TrainingSettings,
|
|
104
106
|
ClearMLConfigMixin,
|
|
105
|
-
TrainingParams,
|
|
106
107
|
):
|
|
107
108
|
"""Training parameters configuration with ClearML features support (config syncing, model identifiers tracking and etc)."""
|
|
108
109
|
|
|
@@ -9,7 +9,7 @@ from transformers import PreTrainedModel
|
|
|
9
9
|
try:
|
|
10
10
|
from peft import PeftConfig
|
|
11
11
|
except ImportError:
|
|
12
|
-
PeftConfig = None
|
|
12
|
+
PeftConfig = None # ty: ignore
|
|
13
13
|
|
|
14
14
|
from kostyl.utils.logging import log_incompatible_keys
|
|
15
15
|
from kostyl.utils.logging import setup_logger
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
kostyl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
kostyl/ml_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
kostyl/ml_core/clearml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
kostyl/ml_core/clearml/config_mixin.py,sha256=
|
|
5
|
-
kostyl/ml_core/clearml/dataset_utils.py,sha256=
|
|
4
|
+
kostyl/ml_core/clearml/config_mixin.py,sha256=sN24RPs8kWW1iXpIr_6w1bfEZZSXIV_i_RXypqzjwXg,3368
|
|
5
|
+
kostyl/ml_core/clearml/dataset_utils.py,sha256=eij_sr2KDhm8GxEbVbK8aBjPsuVvLl9-PIGGaKVgXLA,1729
|
|
6
6
|
kostyl/ml_core/clearml/logging_utils.py,sha256=GBjIIZbH_itd5sj7XpvxjkyZwxxGOpEcQ3BiWaJTyq8,1210
|
|
7
7
|
kostyl/ml_core/clearml/pulling_utils.py,sha256=Yf70ux8dS0_ENdvfbNQkXOrDxwd4ed2GnRCmOR2ppEk,3252
|
|
8
|
-
kostyl/ml_core/configs/__init__.py,sha256=
|
|
9
|
-
kostyl/ml_core/configs/
|
|
8
|
+
kostyl/ml_core/configs/__init__.py,sha256=pBuEhcumGBNncprqz-t_IGll2XtMmogTn9S6ZPHXCTg,997
|
|
9
|
+
kostyl/ml_core/configs/base_model.py,sha256=Sj4vF1zPpEPOVZ3OHDokp_yh80aU27qwTo116tB0xiM,1624
|
|
10
10
|
kostyl/ml_core/configs/hyperparams.py,sha256=u-7FIM-cD3nz9Sycuvg7r0Vdiu4pduafiCoAxq8JK0s,3011
|
|
11
|
-
kostyl/ml_core/configs/
|
|
11
|
+
kostyl/ml_core/configs/training_settings.py,sha256=1pnhFGmeRZS7YKWrGR7rSCXF_eJIZeX2Rkr_NRBAFNk,2650
|
|
12
12
|
kostyl/ml_core/dist_utils.py,sha256=G8atjzkRbXZZiZh9rdEYBmeXqX26rJdDDovft2n6xiU,3201
|
|
13
13
|
kostyl/ml_core/lightning/__init__.py,sha256=-F3JAyq8KU1d-nACWryGu8d1CbvWbQ1rXFdeRwfE2X8,175
|
|
14
14
|
kostyl/ml_core/lightning/callbacks/__init__.py,sha256=Vd-rozY4T9Prr3IMqbliXxj6sC6y9XsovHQqRwzc2HI,297
|
|
@@ -17,7 +17,7 @@ kostyl/ml_core/lightning/callbacks/early_stopping.py,sha256=nEj3OkMNJkpQzR6pt0Z0
|
|
|
17
17
|
kostyl/ml_core/lightning/callbacks/registry_uploading.py,sha256=1aqT38FVOMQo4JphXcyjyK3ZY6A6HF1JBOsKqYNXar8,4706
|
|
18
18
|
kostyl/ml_core/lightning/extenstions/__init__.py,sha256=OY6QGv1agYgqqKf1xJBrxgp_i8FunVfPzYezfaRrGXU,182
|
|
19
19
|
kostyl/ml_core/lightning/extenstions/custom_module.py,sha256=8Z9iT7kdfLkzBQ8nLaCIxolXytiQqFVRLDSaNACjfK8,6146
|
|
20
|
-
kostyl/ml_core/lightning/extenstions/pretrained_model.py,sha256=
|
|
20
|
+
kostyl/ml_core/lightning/extenstions/pretrained_model.py,sha256=4Ng4xjt3KFWKT0UThC_9vM5Y95AhBdzrU4y4We1gemc,4685
|
|
21
21
|
kostyl/ml_core/lightning/loggers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
22
|
kostyl/ml_core/lightning/loggers/tb_logger.py,sha256=Zh9n-lLu-bXMld-FIUO3lJfCyDf0IQFhS3JVShDJmvg,937
|
|
23
23
|
kostyl/ml_core/lightning/steps_estimation.py,sha256=fTZ0IrUEZV3H6VYlx4GYn56oco56mMiB7FO9F0Z7qc4,1511
|
|
@@ -31,6 +31,6 @@ kostyl/utils/__init__.py,sha256=hkpmB6c5pr4Ti5BshOROebb7cvjDZfNCw83qZ_FFKMM,240
|
|
|
31
31
|
kostyl/utils/dict_manipulations.py,sha256=e3vBicID74nYP8lHkVTQc4-IQwoJimrbFELy5uSF6Gk,1073
|
|
32
32
|
kostyl/utils/fs.py,sha256=gAQNIU4R_2DhwjgzOS8BOMe0gZymtY1eZwmdgOdDgqo,510
|
|
33
33
|
kostyl/utils/logging.py,sha256=3MvfDPArZhwakHu5nMlp_LpOsWg0E0SP26y41clsBtA,5232
|
|
34
|
-
kostyl_toolkit-0.1.
|
|
35
|
-
kostyl_toolkit-0.1.
|
|
36
|
-
kostyl_toolkit-0.1.
|
|
34
|
+
kostyl_toolkit-0.1.8.dist-info/WHEEL,sha256=3id4o64OvRm9dUknh3mMJNcfoTRK08ua5cU6DFyVy-4,79
|
|
35
|
+
kostyl_toolkit-0.1.8.dist-info/METADATA,sha256=as5lkkeSw0gVJqEMTm9h4Vdq1P6Div7CHY35TfZVGLs,4268
|
|
36
|
+
kostyl_toolkit-0.1.8.dist-info/RECORD,,
|