CooperativeFox72 could you expand on "not working"?
If you have a yaml file, I would do:
` # local_path = './my_config.yaml'
path = task.connect_configuration(local_path, name=name)
if task.running_locally():
with open(local_path, "r") as config_file:
my_params_dict = yaml.load(config_file, Loader=yaml.FullLoader)
my_params_dict['change_me'] = 'new value'
my_params_text = yaml.dump(my_params_dict)
store back the change, my_params assumed to be the content of the param file (text)
task.set_configuration_object(name=name, config_text=my_params_text) `
Hi CooperativeFox72 ,
When running remotely, connect_configuration(path, name=name)
will write the contents (stored in the task from the original connected file when running locally) into a temporary file, and return its path.
I'm not sure I understand your use-case - do you always want to change the contents of the file in your code? Why not change it before connecting?
From the UI it will since it getting the temp file from there.
I mean from the code (let say remotely)
I tried without yaml.dump(my_params_dict)
will try with it..
so the file was not the same as the connect_configuration uploaded
Thanks
This one should work:
` path = task.connect_configuration(path, name=name)
if task.running_locally():
my_params = read_from_path(path)
my_params = change_parmas(my_params) # change some staff
store back the change, my_params assumed to be the content of the param file (text)
task.set_configuration_object(name=name, config_taxt=my_params) `
So if I will edit the temp file
you mean from the UI or code?
I tried you solution but since my path is to a YAML file,
and task.set_configuration_object(name=name, config_taxt=my_params)
upload this not in the same format task.connect_configuration(path, name=name)
it not working for me 😞
(even when I am using config_type='yaml'
)
CooperativeFox72 a bit of info on how it works:
In "manual" execution (i.e. without an agent)
path = task.connect_configuration(local_path, name=name
path = local_path , and the content of local_path is stored on the Task
In "remote" execution (i.e. agent)
path = task.connect_configuration(local_path, name=name
"local_path" is ignored, path is a temp file, and the content of the temp file is the content that is stored (or edited) on the Task configuration.
Make sense ?
Hi SuccessfulKoala55 and AgitatedDove14 ,
Thanks for the quick replay.
I'm not sure I understand your use-case - do you always want to change the contents of the file in your code? Why not change it before connecting?
Changing the file before the connect will make sense only when I am running locally and the file exists. Remotely I must get the file with connect_configuration(path, name=name)
before I am reading it.
"local_path" is ignored, path is a temp file, and the content of the temp file is the content that is stored (or edited) on the Task configuration.
Make sense ?
So if I will edit the temp file (after using the connect_configuration
), how it will be shown on the server?