oh, it is indeed misleading.
what should I assign to internal_task_representation.execution.script
then (per your example snippet)? a dictionary?
Hi HandsomeCrow5 ,
Try doing the following:from trains.backend_api.services import tasks ... script = tasks.Script(...)
yes 🙂
But I think that when you get the internal_task_representation.execution.script you are basically already getting the API object (obviously with the correct version) so you can edit it in place and pass it too
HandsomeCrow5 if you want to edit the Task object you can just use:internal_task_representation = task.data internal_task_representation.execution.script = ... task._edit(execution=internal_task_representation.execution)
This will make sure you do not need to worry about API version etc. the Task object will take care of it.
BTW: it seems a few more people wanted this ability, maybe we should edit a proper .edit method to Task. Thoughts ?
HandsomeCrow5
So using the _edit
method you have the ability to add/edit the execution.script field, without worrying about the API version (I guess the name edit
is misleading, it also does add :)
Thanks for the prompt response SuccessfulKoala55 ! exactly what I was looking for 🙂
AgitatedDove14 - using your suggested solution looks a bit more generic, and a proper .edit
method is a good idea for that. However - it doesn’t resolve the API version issue I had (that is, unless you also suggest to add a method to add execution.script
, which isn’t initialized when I use Task.create
)