multiml.TaskScheduler

class multiml.TaskScheduler(ordered_tasks=None)

Task management class for multiml execution.

Manage tasks and subtasks. Ordering of tasks are controlled by DAG by providing parents and childs dependencies.

Examples

>>> subtask = MyTask()
>>> task_scheduler = TaskScheduler()
>>> task_scheduler.add_task('task_id')
>>> task_scheduler.add_subtask('task_id', 'subtask_id', subtask)
>>> task_scheduler.get_sorted_task_ids()
__init__(ordered_tasks=None)

Initialize the TaskScheduler and reset DAG.

ordered_tasks option provides a shortcut of registering ordered task and subtask. Please see add_ordered_tasks() and add_ordered_subtasks() methods for details. If task dependencies are complex, please add task and subtask using add_task() and add_subtask() methods.

Parameters:

ordered_tasks (list) – list of ordered task_ids, or list of ordered subtasks. If given value is list of str, add_ordered_tasks() is called to register task_ids. If given value is list of other types, add_ordered_subtasks() is called to register subtasks.

Examples

>>> # ordered task_ids
>>> task_scheduler = TaskScheduler(['task0', 'task1'])
>>> task_scheduler.add_subtask('task0', 'subtask0', env)

Methods

__init__([ordered_tasks])

Initialize the TaskScheduler and reset DAG.

add_ordered_subtasks(ordered_tasks)

Register ordered subtasks.

add_ordered_tasks(ordered_tasks)

Register ordered tasks.

add_subtask(task_id[, subtask_id, env, hps])

Register a subtask to given task.

add_task(task_id[, parents, children, ...])

Register task and add the relation between tasks.

get_all_subtasks_with_hps()

Returns all combination of subtask_ids and hps for all task_ids.

get_children_task_ids(task_id)

Returns child task_ids for given task_id.

get_parents_task_ids(task_id)

Returns parent task_ids for given task_id.

get_sorted_task_ids()

Returns topologically sorted task_ids.

get_subtask(task_id, subtask_id)

Returns subtasktuple for given task_id and subtask_id.

get_subtask_ids(task_id)

Returns subtask_ids by task_id.

get_subtasks(task_id)

Returns subtasks of tasktuple for given task_id.

get_subtasks_pipeline(index)

Returns modified subtasktuples for given index.

get_subtasks_with_hps(task_id)

Returns all combination of subtask_ids and hps for given task_id.

show_info()

Show information of registered tasks and subtasks.

__init__(ordered_tasks=None)

Initialize the TaskScheduler and reset DAG.

ordered_tasks option provides a shortcut of registering ordered task and subtask. Please see add_ordered_tasks() and add_ordered_subtasks() methods for details. If task dependencies are complex, please add task and subtask using add_task() and add_subtask() methods.

Parameters:

ordered_tasks (list) – list of ordered task_ids, or list of ordered subtasks. If given value is list of str, add_ordered_tasks() is called to register task_ids. If given value is list of other types, add_ordered_subtasks() is called to register subtasks.

Examples

>>> # ordered task_ids
>>> task_scheduler = TaskScheduler(['task0', 'task1'])
>>> task_scheduler.add_subtask('task0', 'subtask0', env)
__len__()

Returns number of all grid combination.

Returns:

the number of all grid combination.

Return type:

int

__getitem__(item)

Returns subtasktuples by index.

Parameters:

item (int) – Index between 0 to len(task_scheduler).

Examples

>>> task_scheduler[0]