Task¶
A job runs a recipe step one or more times. The protocol identifies one
run with a TaskId message: the step ID
plus a list of task numbers. Most other Momotor code uses a single dotted
string instead, such as compile.0 for the first task of the step named
compile.
This module converts between the two forms:
from momotor.rpc.proto.task_pb2 import TaskId
from momotor.rpc.task import get_step_task_id
print(get_step_task_id(TaskId(stepId='compile', taskNumber=[0])))
The example prints compile.0. A step without task numbers gives just
the step ID.
API reference¶
- momotor.rpc.task.get_dotted_task_number(task_num)¶
Convert a task-number list into a dotted task-number. If task_num is empty or None, returns None
>>> get_dotted_task_number(None) is None True
>>> get_dotted_task_number([]) is None True
>>> get_dotted_task_number([0]) '0'
>>> get_dotted_task_number([0, 0]) '0.0'
- momotor.rpc.task.get_step_task_id(task_id)¶
Get the step task id from the TaskId message
A step-task-id is the step-id followed with dot-separated sub task number(s)
>>> get_step_task_id(TaskId(stepId='step')) 'step'
>>> get_step_task_id(TaskId(stepId='step', taskNumber=[0])) 'step.0'
>>> get_step_task_id(TaskId(stepId='step', taskNumber=[0, 0])) 'step.0.0'