kostyl-toolkit 0.1.15__py3-none-any.whl → 0.1.17__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.
@@ -15,8 +15,11 @@ from kostyl.ml.lightning.extenstions.pretrained_model import (
15
15
 
16
16
 
17
17
  def get_tokenizer_from_clearml(
18
- model_id: str, task: Task | None = None, ignore_remote_overrides: bool = True
19
- ) -> PreTrainedTokenizerBase:
18
+ model_id: str,
19
+ task: Task | None = None,
20
+ ignore_remote_overrides: bool = True,
21
+ name: str | None = None,
22
+ ) -> tuple[PreTrainedTokenizerBase, InputModel]:
20
23
  """
21
24
  Retrieve a Hugging Face tokenizer stored in a ClearML.
22
25
 
@@ -26,15 +29,19 @@ def get_tokenizer_from_clearml(
26
29
  the model. Defaults to None.
27
30
  ignore_remote_overrides (bool, optional): Whether to ignore remote hyperparameter
28
31
  overrides when connecting the ClearML task. Defaults to True.
32
+ name: The model name to be stored on the Task
33
+ (default to filename of the model weights, without the file extension, or to Input Model if that is not found)
29
34
 
30
35
  Returns:
31
- PreTrainedTokenizerBase: The instantiated tokenizer loaded from the local copy
32
- of the referenced ClearML InputModel.
36
+ The instantiated tokenizer loaded from the local copy
37
+ of the referenced ClearML InputModel and the ClearML InputModel instance.
33
38
 
34
39
  """
35
40
  clearml_tokenizer = InputModel(model_id=model_id)
36
41
  if task is not None:
37
- clearml_tokenizer.connect(task, ignore_remote_overrides=ignore_remote_overrides)
42
+ clearml_tokenizer.connect(
43
+ task, ignore_remote_overrides=ignore_remote_overrides, name=name
44
+ )
38
45
 
39
46
  tokenizer = AutoTokenizer.from_pretrained(
40
47
  clearml_tokenizer.get_local_copy(raise_on_error=True)
@@ -49,8 +56,9 @@ def get_model_from_clearml[
49
56
  model: type[TModel],
50
57
  task: Task | None = None,
51
58
  ignore_remote_overrides: bool = True,
59
+ name: str | None = None,
52
60
  **kwargs: Any,
53
- ) -> TModel:
61
+ ) -> tuple[TModel, InputModel]:
54
62
  """
55
63
  Retrieve a pretrained model from ClearML and instantiate it using the appropriate loader.
56
64
 
@@ -59,18 +67,24 @@ def get_model_from_clearml[
59
67
  model: The model class that implements either PreTrainedModel or LightningCheckpointLoaderMixin.
60
68
  task: Optional ClearML task used to resolve the input model reference. If provided, the input model
61
69
  will be connected to this task, with remote overrides optionally ignored.
62
- ignore_remote_overrides: When connecting the input model to the provided task, determines whether
63
- remote configuration overrides should be ignored.
70
+ ignore_remote_overrides: When connecting the input model to the provided task,
71
+ determines whether remote configuration overrides should be ignored.
72
+ name: The model name to be stored on the Task
73
+ (default to filename of the model weights, without the file extension, or to Input Model if that is not found)
64
74
  **kwargs: Additional keyword arguments to pass to the model loading method.
65
75
 
66
76
  Returns:
67
- An instantiated model loaded either from a ClearML package directory or a Lightning checkpoint.
77
+ The instantiated model and the ClearML InputModel instance.
68
78
 
69
79
  """
70
80
  input_model = InputModel(model_id=model_id)
71
81
 
72
82
  if task is not None:
73
- input_model.connect(task, ignore_remote_overrides=ignore_remote_overrides)
83
+ input_model.connect(
84
+ task,
85
+ ignore_remote_overrides=ignore_remote_overrides,
86
+ name=name,
87
+ )
74
88
 
75
89
  local_path = Path(input_model.get_local_copy(raise_on_error=True))
76
90
 
@@ -88,4 +102,4 @@ def get_model_from_clearml[
88
102
  "Expected a ClearML package directory or a .ckpt file."
89
103
  )
90
104
  model_instance = cast(TModel, model_instance)
91
- return model_instance
105
+ return model_instance, input_model
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: kostyl-toolkit
3
- Version: 0.1.15
3
+ Version: 0.1.17
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
@@ -3,7 +3,7 @@ kostyl/ml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  kostyl/ml/clearml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  kostyl/ml/clearml/dataset_utils.py,sha256=eij_sr2KDhm8GxEbVbK8aBjPsuVvLl9-PIGGaKVgXLA,1729
5
5
  kostyl/ml/clearml/logging_utils.py,sha256=GBjIIZbH_itd5sj7XpvxjkyZwxxGOpEcQ3BiWaJTyq8,1210
6
- kostyl/ml/clearml/pulling_utils.py,sha256=-9EIMUu3daWLj99s_G5rJ_omykz1nPLqxBzBJ8Am8aU,3520
6
+ kostyl/ml/clearml/pulling_utils.py,sha256=I6B8YF3gv9QXsggMRD2RSA2bcEcPUUhsnQjZf-uI0es,4058
7
7
  kostyl/ml/configs/__init__.py,sha256=IetcivbqYGutowLqxdKp7QR4tkXKBr4m8t4Zkk9jHZU,911
8
8
  kostyl/ml/configs/base_model.py,sha256=Eofn14J9RsjpVx_J4rp6C19pDDCANU4hr3JtX-d0FpQ,4820
9
9
  kostyl/ml/configs/hyperparams.py,sha256=CaVNEvpW4LvlHhLsbe2FockIGI1mJufCqjH298nYgKE,2971
@@ -30,6 +30,6 @@ kostyl/utils/__init__.py,sha256=hkpmB6c5pr4Ti5BshOROebb7cvjDZfNCw83qZ_FFKMM,240
30
30
  kostyl/utils/dict_manipulations.py,sha256=e3vBicID74nYP8lHkVTQc4-IQwoJimrbFELy5uSF6Gk,1073
31
31
  kostyl/utils/fs.py,sha256=gAQNIU4R_2DhwjgzOS8BOMe0gZymtY1eZwmdgOdDgqo,510
32
32
  kostyl/utils/logging.py,sha256=3MvfDPArZhwakHu5nMlp_LpOsWg0E0SP26y41clsBtA,5232
33
- kostyl_toolkit-0.1.15.dist-info/WHEEL,sha256=3id4o64OvRm9dUknh3mMJNcfoTRK08ua5cU6DFyVy-4,79
34
- kostyl_toolkit-0.1.15.dist-info/METADATA,sha256=ieM22BLWafdzv4x7f7zaCz_Yhbe1Qce22w0L2i3mK-c,4269
35
- kostyl_toolkit-0.1.15.dist-info/RECORD,,
33
+ kostyl_toolkit-0.1.17.dist-info/WHEEL,sha256=3id4o64OvRm9dUknh3mMJNcfoTRK08ua5cU6DFyVy-4,79
34
+ kostyl_toolkit-0.1.17.dist-info/METADATA,sha256=T547zPqZpJcgiXR2SAloz2W7_MCNhhhxlTsgzdWkXlo,4269
35
+ kostyl_toolkit-0.1.17.dist-info/RECORD,,