kostyl-toolkit 0.1.4__tar.gz → 0.1.6__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.4 → kostyl_toolkit-0.1.6}/PKG-INFO +1 -1
  2. kostyl_toolkit-0.1.6/kostyl/ml_core/clearml/dataset_utils.py +61 -0
  3. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/configs/hyperparams.py +2 -3
  4. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/lightning/extenstions/pretrained_model.py +3 -3
  5. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/pyproject.toml +1 -1
  6. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/README.md +0 -0
  7. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/__init__.py +0 -0
  8. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/__init__.py +0 -0
  9. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/clearml/__init__.py +0 -0
  10. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/clearml/config_mixin.py +0 -0
  11. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/clearml/logging_utils.py +0 -0
  12. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/clearml/pulling_utils.py +0 -0
  13. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/configs/__init__.py +0 -0
  14. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/configs/base.py +0 -0
  15. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/configs/training_params.py +0 -0
  16. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/dist_utils.py +0 -0
  17. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/lightning/__init__.py +0 -0
  18. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/lightning/callbacks/__init__.py +0 -0
  19. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/lightning/callbacks/checkpoint.py +0 -0
  20. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/lightning/callbacks/early_stopping.py +0 -0
  21. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/lightning/callbacks/registry_uploading.py +0 -0
  22. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/lightning/extenstions/__init__.py +0 -0
  23. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/lightning/extenstions/custom_module.py +0 -0
  24. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/lightning/loggers/__init__.py +0 -0
  25. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/lightning/loggers/tb_logger.py +0 -0
  26. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/lightning/steps_estimation.py +0 -0
  27. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/metrics_formatting.py +0 -0
  28. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/params_groups.py +0 -0
  29. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/schedulers/__init__.py +0 -0
  30. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/schedulers/base.py +0 -0
  31. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/schedulers/composite.py +0 -0
  32. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/ml_core/schedulers/cosine.py +0 -0
  33. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/utils/__init__.py +0 -0
  34. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/utils/dict_manipulations.py +0 -0
  35. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/kostyl/utils/fs.py +0 -0
  36. {kostyl_toolkit-0.1.4 → kostyl_toolkit-0.1.6}/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.4
3
+ Version: 0.1.6
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
@@ -0,0 +1,61 @@
1
+ from concurrent.futures import ThreadPoolExecutor
2
+ from concurrent.futures import as_completed
3
+ from pathlib import Path
4
+
5
+ from clearml import Dataset as ClearMLDataset
6
+
7
+
8
+ def collect_clearml_datasets(
9
+ datasets_mapping: dict[str, str],
10
+ ) -> dict[str, ClearMLDataset]:
11
+ """
12
+ Collect ClearML datasets by dataset ID.
13
+
14
+ Args:
15
+ datasets_mapping: Mapping where keys are human-readable names and values
16
+ are ClearML dataset IDs.
17
+
18
+ Returns:
19
+ A mapping of dataset names to fetched `ClearMLDataset` instances.
20
+
21
+ """
22
+ datasets_list = {}
23
+ for name, dataset_id in datasets_mapping.items():
24
+ clearml_dataset = ClearMLDataset.get(dataset_id, alias=name)
25
+ datasets_list[name] = clearml_dataset
26
+ return datasets_list
27
+
28
+
29
+ def download_clearml_datasets(datasets_mapping: dict[str, ClearMLDataset]) -> None:
30
+ """
31
+ Download all ClearML datasets in parallel.
32
+
33
+ Args:
34
+ datasets_mapping: Mapping of dataset names to initialized
35
+ `ClearMLDataset` instances whose contents must be downloaded
36
+ locally.
37
+
38
+ """
39
+ with ThreadPoolExecutor() as executor:
40
+ futures = [
41
+ executor.submit(ds.get_local_copy) for ds in datasets_mapping.values()
42
+ ]
43
+ for future in as_completed(futures):
44
+ future.result()
45
+ return
46
+
47
+
48
+ def get_datasets_paths(datasets_mapping: dict[str, ClearMLDataset]) -> dict[str, Path]:
49
+ """
50
+ Return local filesystem paths for ClearML datasets.
51
+
52
+ Args:
53
+ datasets_mapping: Mapping of dataset names to initialized
54
+ `ClearMLDataset` instances.
55
+
56
+ Returns:
57
+ Mapping of dataset names to local `Path` objects pointing to the
58
+ downloaded dataset copies.
59
+
60
+ """
61
+ return {name: Path(ds.get_local_copy()) for name, ds in datasets_mapping.items()}
@@ -2,10 +2,9 @@ from pydantic import BaseModel
2
2
  from pydantic import Field
3
3
  from pydantic import model_validator
4
4
 
5
+ from kostyl.ml_core.clearml.config_mixin import ClearMLConfigMixin
5
6
  from kostyl.utils.logging import setup_logger
6
7
 
7
- from .base import ClearMLBaseModel
8
-
9
8
 
10
9
  logger = setup_logger(fmt="only_message")
11
10
 
@@ -75,7 +74,7 @@ class WeightDecay(BaseModel):
75
74
  return self
76
75
 
77
76
 
78
- class HyperparamsConfig(ClearMLBaseModel):
77
+ class HyperparamsConfig(BaseModel, ClearMLConfigMixin):
79
78
  """Model training hyperparameters configuration."""
80
79
 
81
80
  grad_clip_val: float | None = Field(default=None, gt=0, validate_default=False)
@@ -27,7 +27,7 @@ class LightningCheckpointLoaderMixin(PreTrainedModel):
27
27
  checkpoint_path: str | Path,
28
28
  config_key: str = "config",
29
29
  weights_prefix: str = "model.",
30
- log_incompatible: bool = True,
30
+ should_log_incompatible_keys: bool = True,
31
31
  ) -> TModelInstance:
32
32
  """
33
33
  Load a model from a Lightning checkpoint file.
@@ -47,7 +47,7 @@ class LightningCheckpointLoaderMixin(PreTrainedModel):
47
47
  Defaults to "config".
48
48
  weights_prefix (str, optional): Prefix to strip from state dict keys. Defaults to "model.".
49
49
  If not empty and doesn't end with ".", a "." is appended.
50
- log_incompatible (bool, optional): Whether to log incompatible keys. Defaults to True.
50
+ should_log_incompatible_keys (bool, optional): Whether to log incompatible keys. Defaults to True.
51
51
 
52
52
  Returns:
53
53
  TModelInstance: The loaded model instance.
@@ -110,6 +110,6 @@ class LightningCheckpointLoaderMixin(PreTrainedModel):
110
110
  )
111
111
  incompatible_keys["missing_keys"] = missing_keys
112
112
  incompatible_keys["unexpected_keys"] = unexpected_keys
113
- if log_incompatible:
113
+ if should_log_incompatible_keys:
114
114
  log_incompatible_keys(incompatible_keys=incompatible_keys, logger=logger)
115
115
  return model
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "kostyl-toolkit"
3
- version = "0.1.4"
3
+ version = "0.1.6"
4
4
  description = "Kickass Orchestration System for Training, Yielding & Logging "
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
File without changes