mirror of
https://github.com/clearml/clearml
synced 2025-05-31 02:28:09 +00:00
Deprecate Task.set_model_config(), Task.get_model_config_text() and Task.get_model_config_dict()
This commit is contained in:
parent
023f1721c1
commit
0211d233d4
@ -116,10 +116,10 @@ Task.current_task().set_model_label_enumeration( {"label": int(0), } )
|
||||
|
||||
### Can I store the model configuration file as well? <a name="store-model-configuration"></a>
|
||||
|
||||
Yes! Use the `Task.set_model_config()` method:
|
||||
Yes! Use the `Task.connect_configuration()` method:
|
||||
|
||||
```python
|
||||
Task.current_task().set_model_config("a very long text with the configuration file's content")
|
||||
Task.current_task().connect_configuration("/path/to/file")
|
||||
```
|
||||
|
||||
### I am training multiple models at the same time, but I only see one of them. What happened? <a name="only-last-model-appears"></a>
|
||||
|
@ -90,7 +90,7 @@ model.compile(loss='categorical_crossentropy',
|
||||
|
||||
# Connecting TRAINS
|
||||
task = Task.init(project_name='examples', task_name='Keras with TensorBoard example')
|
||||
task.set_model_config(config_dict={'test': 1337, 'nested': {'key': 'value', 'number': 1}})
|
||||
task.connect_configuration({'test': 1337, 'nested': {'key': 'value', 'number': 1}})
|
||||
|
||||
# Advanced: setting model class enumeration
|
||||
labels = dict(('digit_%d' % i, i) for i in range(10))
|
||||
|
@ -628,8 +628,8 @@ class InputModel(Model):
|
||||
if model.id != self._EMPTY_MODEL_ID:
|
||||
task.set_input_model(model_id=model.id)
|
||||
# only copy the model design if the task has no design to begin with
|
||||
if not self._task.get_model_config_text():
|
||||
task.set_model_config(config_text=model.model_design)
|
||||
if not self._task._get_model_config_text():
|
||||
task._set_model_config(config_text=model.model_design)
|
||||
if not self._task.get_labels_enumeration():
|
||||
task.set_model_label_enumeration(model.data.labels)
|
||||
|
||||
@ -798,22 +798,22 @@ class OutputModel(BaseModel):
|
||||
|
||||
if running_remotely() and task.is_main_task():
|
||||
if self._floating_data:
|
||||
self._floating_data.design = _Model._wrap_design(self._task.get_model_config_text()) or \
|
||||
self._floating_data.design = _Model._wrap_design(self._task._get_model_config_text()) or \
|
||||
self._floating_data.design
|
||||
self._floating_data.labels = self._task.get_labels_enumeration() or \
|
||||
self._floating_data.labels
|
||||
elif self._base_model:
|
||||
self._base_model.update(design=_Model._wrap_design(self._task.get_model_config_text()) or
|
||||
self._base_model.update(design=_Model._wrap_design(self._task._get_model_config_text()) or
|
||||
self._base_model.design)
|
||||
self._base_model.update(labels=self._task.get_labels_enumeration() or self._base_model.labels)
|
||||
|
||||
elif self._floating_data is not None:
|
||||
# we copy configuration / labels if they exist, obviously someone wants them as the output base model
|
||||
if _Model._unwrap_design(self._floating_data.design):
|
||||
if not task.get_model_config_text():
|
||||
task.set_model_config(config_text=self._floating_data.design)
|
||||
if not task._get_model_config_text():
|
||||
task._set_model_config(config_text=self._floating_data.design)
|
||||
else:
|
||||
self._floating_data.design = _Model._wrap_design(self._task.get_model_config_text())
|
||||
self._floating_data.design = _Model._wrap_design(self._task._get_model_config_text())
|
||||
|
||||
if self._floating_data.labels:
|
||||
task.set_model_label_enumeration(self._floating_data.labels)
|
||||
@ -1037,8 +1037,8 @@ class OutputModel(BaseModel):
|
||||
|
||||
config_text = self._resolve_config(config_text=config_text, config_dict=config_dict)
|
||||
|
||||
if self._task and not self._task.get_model_config_text():
|
||||
self._task.set_model_config(config_text=config_text)
|
||||
if self._task and not self._task._get_model_config_text():
|
||||
self._task._set_model_config(config_text=config_text)
|
||||
|
||||
if self.id:
|
||||
# update the model object (this will happen if we resumed a training task)
|
||||
@ -1095,7 +1095,7 @@ class OutputModel(BaseModel):
|
||||
self._base_model = self._task.create_output_model()
|
||||
# update the model from the task inputs
|
||||
labels = self._task.get_labels_enumeration()
|
||||
config_text = self._task.get_model_config_text()
|
||||
config_text = self._task._get_model_config_text()
|
||||
parent = self._task.output_model_id or self._task.input_model_id
|
||||
self._base_model.update(
|
||||
labels=self._floating_data.labels or labels,
|
||||
|
@ -842,38 +842,28 @@ class Task(_Task):
|
||||
return self is self.__main_task
|
||||
|
||||
def set_model_config(self, config_text=None, config_dict=None):
|
||||
# type: (Optional[str], Optional[Mapping]) -> None
|
||||
"""
|
||||
Set Task model configuration text/dict (before creating an output model)
|
||||
When an output model is created it will inherit these properties
|
||||
|
||||
:param config_text: model configuration (unconstrained text string). usually the content of a configuration file.
|
||||
If `config_text` is not None, `config_dict` must not be provided.
|
||||
:param config_dict: model configuration parameters dictionary.
|
||||
If `config_dict` is not None, `config_text` must not be provided.
|
||||
.. deprecated:: 0.14.1
|
||||
Use :func:`connect_configuration` instead
|
||||
"""
|
||||
design = OutputModel._resolve_config(config_text=config_text, config_dict=config_dict)
|
||||
super(Task, self)._set_model_design(design=design)
|
||||
self._set_model_config(config_text=config_text, config_dict=config_dict)
|
||||
|
||||
def get_model_config_text(self):
|
||||
# type: () -> str
|
||||
"""
|
||||
Get Task model configuration text (before creating an output model)
|
||||
When an output model is created it will inherit these properties
|
||||
|
||||
:return: model config_text (unconstrained text string). usually the content of a configuration file.
|
||||
If `config_text` is not None, `config_dict` must not be provided.
|
||||
.. deprecated:: 0.14.1
|
||||
Use :func:`connect_configuration` instead
|
||||
"""
|
||||
return super(Task, self).get_model_design()
|
||||
return self._get_model_config_text()
|
||||
|
||||
def get_model_config_dict(self):
|
||||
# type: () -> Dict
|
||||
"""
|
||||
Get Task model configuration dictionary (before creating an output model)
|
||||
When an output model is created it will inherit these properties
|
||||
|
||||
:return: model config_text (unconstrained text string). usually the content of a configuration file.
|
||||
If `config_text` is not None, `config_dict` must not be provided.
|
||||
.. deprecated:: 0.14.1
|
||||
Use :func:`connect_configuration` instead
|
||||
"""
|
||||
config_text = self.get_model_config_text()
|
||||
return OutputModel._text_to_config_dict(config_text)
|
||||
return self._get_model_config_dict()
|
||||
|
||||
def set_model_label_enumeration(self, enumeration=None):
|
||||
"""
|
||||
@ -988,6 +978,40 @@ class Task(_Task):
|
||||
Session.default_web = web_host or ''
|
||||
Session.default_files = files_host or ''
|
||||
|
||||
def _set_model_config(self, config_text=None, config_dict=None):
|
||||
# type: (Optional[str], Optional[Mapping]) -> None
|
||||
"""
|
||||
Set Task model configuration text/dict
|
||||
|
||||
:param config_text: model configuration (unconstrained text string). usually the content of a configuration file.
|
||||
If `config_text` is not None, `config_dict` must not be provided.
|
||||
:param config_dict: model configuration parameters dictionary.
|
||||
If `config_dict` is not None, `config_text` must not be provided.
|
||||
"""
|
||||
design = OutputModel._resolve_config(config_text=config_text, config_dict=config_dict)
|
||||
super(Task, self)._set_model_design(design=design)
|
||||
|
||||
def _get_model_config_text(self):
|
||||
# type: () -> str
|
||||
"""
|
||||
Get Task model configuration text (before creating an output model)
|
||||
When an output model is created it will inherit these properties
|
||||
|
||||
:return: model config_text (unconstrained text string)
|
||||
"""
|
||||
return super(Task, self).get_model_design()
|
||||
|
||||
def _get_model_config_dict(self):
|
||||
# type: () -> Dict
|
||||
"""
|
||||
Get Task model configuration dictionary (before creating an output model)
|
||||
When an output model is created it will inherit these properties
|
||||
|
||||
:return: config_dict: model configuration parameters dictionary
|
||||
"""
|
||||
config_text = self._get_model_config_text()
|
||||
return OutputModel._text_to_config_dict(config_text)
|
||||
|
||||
@classmethod
|
||||
def _reset_current_task_obj(cls):
|
||||
if not cls.__main_task:
|
||||
@ -1071,7 +1095,7 @@ class Task(_Task):
|
||||
task.set_comment(make_message('Auto-generated at %(time)s by %(user)s@%(host)s'))
|
||||
# clear the input model (and task model design/labels)
|
||||
task.set_input_model(model_id='', update_task_design=False, update_task_labels=False)
|
||||
task.set_model_config(config_text='')
|
||||
task._set_model_config(config_text='')
|
||||
task.set_model_label_enumeration({})
|
||||
task.set_artifacts([])
|
||||
task._set_storage_uri(None)
|
||||
|
Loading…
Reference in New Issue
Block a user