ColossalDeer61 we can add to the script Task.init
and we will have this service in the UI, with connection to the configuration, users can change the configuration from the UI and send this script to execute (in services queue for example). This way others can change the configuration and run this script.
` from trains import Task
service_task = Task.init(project_name="services", task_name="clone and enqueue by configuration")
configuration_file = {
"stage_1": {
"batch_size": 32,
"epochs": 10
},
"stage_2": {
"batch_size": 64,
"epochs": 20
},
}
service_task.connect(configuration_file)
template_task = Task.get_task(task_id=<YOUR TEMPLATE TASK>)
for name, params in configuration_file.items():
# clone the template task into a new write enabled task (where we can change parameters)
cloned_task = Task.clone(source_task=template_task,
name=template_task.name + ' {}'.format(name),
parent=template_task.id)
# get the original template parameters
cloned_task_parameters = cloned_task.get_parameters()
# override with random samples form grid
for k, cloned_params in params.items():
cloned_task_parameters[k] = cloned_params
# put back into the new cloned task
cloned_task.set_parameters(cloned_task_parameters)
print('Experiment {} set with parameters {}'.format(name, cloned_task_parameters))
# enqueue the task for execution
Task.enqueue(cloned_task.id, queue_name="default") # <--- Change "default" to your queue name
print('Experiment id={} enqueue for execution'.format(cloned_task.id)) `