Skip to content

Introduction of looping instruction or goto instruction #348

Description

@evvaaaa

Use Case

Currently the queueserver can be set to loop mode:

if loop_mode:
item_to_add = self.set_new_item_uuid(item)
await self._add_item_to_queue(item_to_add)

This is useful, but there are other situations where my scientists want to run, for example,

  1. 10 plans with differing arguments, repeating 3 times
  2. A single plan to change some condition
  3. Another single plan to change some condition
  4. 7 plans with differing arguments, repeating 10 times
    ... and so on and so fourth with 12 hours worth of plans.

Proposal

Option 1

I propose adding two new instructions:

loop_start

{"name": "loop_start", "options": {"num": N}, "item_type": "instruction"}

Initiates a loop, the plans between this and an exit instruction will be repeated N times.

loop_exit

{"name": "loop_exit", "item_type": "instruction"}

Marks the end of the loop.

Option 2

A more general goto instruction, with some way to handle conditionals:

{"name": "goto", "options": {"absolute_index": N, "repeat_limit": M}, "item_type": "instruction"}

A running queueserver would have state for how many times each goto has been ran and skip them once repeat_limit is reached.

The following would repeat an entire queue forever:

{"name": "goto", "options": {"absolute_index": 0}, "item_type": "instruction"}

We could also allow goto to specify relative index, repeat the last two plans N times:

{"name": "goto", "options": {"relative_index": -2, "repeat_limit": N}, "item_type": "instruction"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions