mirror of
https://github.com/clearml/clearml
synced 2025-06-03 11:27:00 +00:00
Fix Task.set_user_properties() docstring and interface
This commit is contained in:
parent
a28a97b160
commit
22104bed37
@ -86,35 +86,36 @@ class HyperParams(object):
|
|||||||
|
|
||||||
def make_item(value, name=None):
|
def make_item(value, name=None):
|
||||||
if isinstance(value, tasks.ParamsItem):
|
if isinstance(value, tasks.ParamsItem):
|
||||||
item = value
|
a_item = value
|
||||||
elif isinstance(value, dict):
|
elif isinstance(value, dict):
|
||||||
item = tasks.ParamsItem(**value)
|
a_item = tasks.ParamsItem(**{k: None if v is None else str(v) for k, v in value.items()})
|
||||||
|
elif isinstance(value, tuple) and len(value) == 2 and isinstance(value[1], dict) and 'value' in value[1]:
|
||||||
|
a_item = tasks.ParamsItem(
|
||||||
|
name=str(value[0]), **{k: None if v is None else str(v) for k, v in value[1].items()})
|
||||||
elif isinstance(value, tuple):
|
elif isinstance(value, tuple):
|
||||||
item = tasks.ParamsItem(name=str(value[0]), value=str(value[1]))
|
a_item = tasks.ParamsItem(name=str(value[0]), value=str(value[1]))
|
||||||
else:
|
else:
|
||||||
item = tasks.ParamsItem(value=str(value))
|
a_item = tasks.ParamsItem(value=str(value))
|
||||||
|
|
||||||
if name:
|
if name:
|
||||||
item.name = str(name)
|
a_item.name = str(name)
|
||||||
if not item.name:
|
if not a_item.name:
|
||||||
raise ValueError("Missing hyper-param name for '{}'".format(value))
|
raise ValueError("Missing hyper-param name for '{}'".format(value))
|
||||||
section = force_section or item.section or default_section
|
section = force_section or a_item.section or default_section
|
||||||
if not section:
|
if not section:
|
||||||
raise ValueError("Missing hyper-param section for '{}'".format(value))
|
raise ValueError("Missing hyper-param section for '{}'".format(value))
|
||||||
|
# force string value
|
||||||
if escape_unsafe:
|
if escape_unsafe:
|
||||||
item.section, item.name = self._escape_unsafe_values(section, item.name)
|
a_item.section, a_item.name = self._escape_unsafe_values(section, a_item.name)
|
||||||
else:
|
else:
|
||||||
item.section = section
|
a_item.section = section
|
||||||
return item
|
return a_item
|
||||||
|
|
||||||
props = {}
|
props = {}
|
||||||
if isinstance(iterables, dict):
|
if isinstance(iterables, dict):
|
||||||
iterables = [iterables]
|
props.update({name: make_item(name=name, value=value) for name, value in iterables.items()})
|
||||||
|
else:
|
||||||
for i in iterables:
|
for i in iterables:
|
||||||
if isinstance(i, dict):
|
|
||||||
props.update({name: make_item(value, name) for name, value in i.items()})
|
|
||||||
else:
|
|
||||||
item = make_item(i)
|
item = make_item(i)
|
||||||
props.update({item.name: item})
|
props.update({item.name: item})
|
||||||
|
|
||||||
|
@ -1595,6 +1595,14 @@ class Task(_Task):
|
|||||||
* description
|
* description
|
||||||
* type
|
* type
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
task.set_user_properties(backbone='great', stable=True)
|
||||||
|
task.set_user_properties(backbone={"type": int, "description": "network type", "value": "great"}, )
|
||||||
|
task.set_user_properties(
|
||||||
|
{"name": "backbone", "description": "network type", "value": "great"},
|
||||||
|
{"name": "stable", "description": "is stable", "value": True},
|
||||||
|
)
|
||||||
|
|
||||||
:param iterables: Properties iterables, each can be:
|
:param iterables: Properties iterables, each can be:
|
||||||
* A dictionary of string key (name) to either a string value (value) a dict (property details). If the value
|
* A dictionary of string key (name) to either a string value (value) a dict (property details). If the value
|
||||||
is a dict, it must contain a "value" field. For example:
|
is a dict, it must contain a "value" field. For example:
|
||||||
|
Loading…
Reference in New Issue
Block a user