Sure, just by changing a few things from the previous example:
` from clearml import Task
task = Task.init()
task.connect({"metrics": ["nmae", "bias", "r2"]})
metrics_names = task.get_parameter("General/metrics")
print(metrics_names)
print(type(metrics_names)) `
Thanks AgitatedDove14 ! Wow, I was definitely not expecting that behavior 🤣 I will check it out tomorrow. Just one more thing, what do you mean by "my_task_id_that_i_generated_before_here"?
If I try to connect a dictionary of typeÂ
dict[str, list]
 withÂ
task.connect
, when retrieving this dictionary with
Wait, this should work out of the box, do you have any specific example?
get_parameter
returns the value of a parameter as documented:
https://clear.ml/docs/latest/docs/references/sdk/task#get_parameter
Maybe try https://clear.ml/docs/latest/docs/references/sdk/task#get_parameters
Hi AgitatedDove14
Using task.get_parameters
I get the parameters in a dictionary, but the values are still of type 'string'. The quickest solution I can think of is parsing with eval
built-in. wdyt?
eval
 built-in. wdyt?
eval
is never recommended as basically you could do Args/float='os.system("rm ...")'
🙂
In theory type is stored on the hyper parameter (this is a relatively new feature the backend supports)
The casting though, is done based on the Original value type, which means Task.connect needs to be called with the original dict. Is there a specific reason for using get_parameters instead of task.connect ?
Okay I think I found the confusion here (and it is confusing, but also very cool)
This line:metrics_names = {"metrics": ["name", "bias", "r2"]} task.connect(metrics_names)
When running in "manual mode" (i.e. not by an agent), will take the dict metrics_names
and put it on the Tasks HyperParameters section.
But, when executed by the Agent, it will do the opposite! it will take the data stored on the Task's hyperparameters section and put it back into the metrics_names
variable. You can test it with:
Task.debug_simulate_remote_task('my_task_id_that_I_generated_before_here')
metrics_names = {"metrics": ["name", "bias", "r2"]}
task = Task.init(project_name='debug', task_name='check connect dict')
task.connect(metrics_names)
print(metrics_names)
print(type(metrics_names)) `Make sense ?
Hm GiganticTurtle0 let me check quickly it
Task.debug_simulate_remote_task
simulates the Task being executed by the agent (basically same behaviour, only local). the argument it gets is the Task ID (string).
The to see how it works is to run the code once (no debug_simulate call), get the Task ID we created, then rerun with the debug_simulate_remote_task
passing the previous Task.ID
Make sense ?
If I try to connect a dictionary of type dict[str, list]
with task.connect
, when retrieving this dictionary with task.get_parameter
I get another dictionary dict[str, str]
. Therefore, I see the same behavior using task.connect
:/