Closed Weiming-Hu closed 4 years ago
It is in fact expected behavior. In the second case, you are creating one task instance. That one task instance is then changed 10 times - but no new tasks are created. Registering the same task 10 times is not the same as registering 10 different tasks (as in the first case).
Note that the Task
constructor accepts a from_dict
, so you can replace the code with something like
s = Stage()
task_dict = {
't.cpu_reqs': {
'processes' : 10,
'threads_per_process': 1,
'process_type' : "MPI",
'thread_type' : "OpenMP"
}}
for i in range(10):
task_dict['name'] = "task-{}".format(i)
task_dict['arguments'] = ["file-{}".format(i)]
s.add_tasks(Task(from_dict=task_dict))
print("Adding shared tasks. Total: {}".format(len(s.tasks)))
If that is something you prefer. But I don't really see anything wrong with the first version either :-)
HtH, Andre.
@lee212 this also has to go into the documentation.
@Weiming-Hu, task creation: https://radicalentk.readthedocs.io/en/latest/user_guide/adding_tasks.html
I have observed an unexpected behavior (from a user's perspective) of EnTK. Here is a minimal case for reproducing this behavior.
After running the above code, I have the following results:
When I'm trying to add a modified task to a stage, it won't go through. I have to create a new task using
Task()
each time. Is this expected?I can see use case #2 to be helpful sometimes where I have a lot of tasks to create but they only vary in the input file names. It would be nice to define a task template and modify it on top of that.
Thank you