seq  2.0.0
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lib.nodes.sequence.Sequence Class Reference

Basic sequencer node. More...

Inheritance diagram for lib.nodes.sequence.Sequence:
lib.nodes.interface._BaseNode lib.nodes.loop.Loop lib.nodes.observing_block.ObservingBlock lib.nodes.parallel.Parallel lib.nodes.template.Template lib.nodes.recover.RLoop

Public Member Functions

def __attrs_post_init__ (self)
 Assigns node's name and id. More...
 
def __iter__ (self)
 
def context (self)
 Get context dictionary, preferably from root node. More...
 
def context (self, ctx)
 
def seq (self)
 Retrieves the sequence list. More...
 
def seq (self, s)
 List used to create the Sequence's graph. More...
 
def G (self)
 returns the graph object More...
 
def start_step (self)
 
def end_step (self)
 
def start_node (self)
 Returns the start node. More...
 
def end_node (self)
 Returns the end node. More...
 
def append (self, s)
 Appends a node to the Sequence. More...
 
def make_sequence (self)
 Builds this sequence execution graph. More...
 
def create_node_tasks (self, resume=False)
 Creates Task object associated to this node. More...
 
def reschedule_node (self, node_id)
 Reschedule a node for execution. More...
 
def start (self, make_sequence=True, resume=False)
 This is the entry point for Sequence execution. More...
 
def run (self)
 
def execute (self, resume=False)
 
def resume (self)
 
def main_task (self)
 Returns the objective node of the sequence – the end node. More...
 
def __call__ (self, resume=False)
 
def abort (self)
 Aborts the sequence. More...
 
def nodes (self)
 Return nodes from Graph. More...
 
def get_node (self, node_id)
 Get node by id. More...
 
def get_task (self, node_id)
 Get task by node_id. More...
 
def state (self)
 Gets the node state. More...
 
def state (self, value)
 Sets the node state. More...
 
def publish_state (self)
 
def state (self, value)
 Sets the node state. More...
 
- Public Member Functions inherited from lib.nodes.interface._BaseNode
def result (self)
 Node's result. More...
 
def result (self, val)
 
def full_state (self)
 Gets the node state. More...
 
def in_error (self)
 
def skip (self)
 
def skip (self, flag=True)
 
def in_error (self, flag=True)
 
def make_task (self, node, input_list, resume)
 Creates the task object that executes the node. More...
 
def pause (self)
 

Static Public Member Functions

def get_context ()
 
def create (*args, **kw)
 Sequence node constructor. More...
 

Public Attributes

 name
 
 id
 
 serial_number
 
 state
 node state More...
 
 in_error
 
 runtime_flags
 
 t_start
 
 skip
 
 exception
 
 t_end
 

Static Public Attributes

 graph = attr.ib(init=False, default=attr.Factory(nx.DiGraph), repr=False)
 
 debug = attr.ib(init=False, default=False, repr=False)
 
 current_tpl = cv.ContextVar("current_tpl", default=None)
 
 root = cv.ContextVar("root", default=None)
 
- Static Public Attributes inherited from lib.nodes.interface._BaseNode
 serial_number = attr.ib(default=0, kw_only=True)
 
 id = attr.ib(default=None, kw_only=True)
 
 name = attr.ib(default=None, kw_only=True)
 
 runtime_flags = attr.ib(default=0, init=False)
 
 deps = attr.ib(default=attr.Factory(list), repr=False, kw_only=True, init=False)
 
 description = attr.ib(default="", kw_only=True)
 
 exception = attr.ib(init=False, default=None, repr=False)
 
 can_skip = attr.ib(default=True, init=False)
 
 hide = attr.ib(default=False, init=False)
 
 t_start = attr.ib(init=False, default=None, repr=False)
 
 t_end = attr.ib(init=False, default=None, repr=False)
 
 running_checkpoint
 

Detailed Description

Basic sequencer node.

Use :meth:create to build poperly :class:Sequence objects.

============ ===============================

Context Variables

Name Desc ============ =============================== current_tpl The parent of the current node root Top level DAG's root ============ ===============================

Examples

>>> s = Sequence.create(a,b, name="my sequence")
# execute Sequence
>>> await s.start()
# Get running Sequence from Inside function a():
>>> def a():

... current_tpl = Sequence.current_tpl

... # now current_tpl is the node s

... assert current_tpl == s

Member Function Documentation

◆ __attrs_post_init__()

def lib.nodes.sequence.Sequence.__attrs_post_init__ (   self)

◆ __call__()

def lib.nodes.sequence.Sequence.__call__ (   self,
  resume = False 
)

◆ __iter__()

def lib.nodes.sequence.Sequence.__iter__ (   self)

◆ abort()

def lib.nodes.sequence.Sequence.abort (   self)

Aborts the sequence.

   Goes trough the full graph and aborts the tasks associated to nodes (if any).

◆ append()

def lib.nodes.sequence.Sequence.append (   self,
  s 
)

Appends a node to the Sequence.

◆ context() [1/2]

def lib.nodes.sequence.Sequence.context (   self)

Get context dictionary, preferably from root node.

◆ context() [2/2]

def lib.nodes.sequence.Sequence.context (   self,
  ctx 
)

◆ create()

def lib.nodes.sequence.Sequence.create ( args,
**  kw 
)
static

Sequence node constructor.

        *args: Variable length list of nodes or coroutines that compose the
Parameters
sequence.
idNode id
namenode name

Reimplemented in lib.nodes.parallel.Parallel, and lib.nodes.loop.Loop.

◆ create_node_tasks()

def lib.nodes.sequence.Sequence.create_node_tasks (   self,
  resume = False 
)

Creates Task object associated to this node.

◆ end_node()

def lib.nodes.sequence.Sequence.end_node (   self)

Returns the end node.

   If it does not exist, it creates it.

Reimplemented from lib.nodes.interface._BaseNode.

◆ end_step()

def lib.nodes.sequence.Sequence.end_step (   self)
Standard sequence's end step.

 Evaluates the sequence's final state.
 Collects node's result and put them in the sequence's result attribute.

Reimplemented in lib.nodes.loop.Loop.

◆ execute()

def lib.nodes.sequence.Sequence.execute (   self,
  resume = False 
)
Executes node -- this just creates the asyncio task

Reimplemented in lib.nodes.template.Template.

◆ G()

def lib.nodes.sequence.Sequence.G (   self)

returns the graph object

◆ get_context()

def lib.nodes.sequence.Sequence.get_context ( )
static

◆ get_node()

def lib.nodes.sequence.Sequence.get_node (   self,
  node_id 
)

Get node by id.

Reimplemented in lib.nodes.loop.Loop.

◆ get_task()

def lib.nodes.sequence.Sequence.get_task (   self,
  node_id 
)

Get task by node_id.

◆ main_task()

def lib.nodes.sequence.Sequence.main_task (   self)

Returns the objective node of the sequence – the end node.

◆ make_sequence()

def lib.nodes.sequence.Sequence.make_sequence (   self)

Builds this sequence execution graph.

Reimplemented from lib.nodes.interface._BaseNode.

Reimplemented in lib.nodes.parallel.Parallel, and lib.nodes.loop.Loop.

◆ nodes()

def lib.nodes.sequence.Sequence.nodes (   self)

Return nodes from Graph.

Reimplemented in lib.nodes.loop.Loop.

◆ publish_state()

def lib.nodes.sequence.Sequence.publish_state (   self)

◆ reschedule_node()

def lib.nodes.sequence.Sequence.reschedule_node (   self,
  node_id 
)

Reschedule a node for execution.

◆ resume()

def lib.nodes.sequence.Sequence.resume (   self)
Resume node execution

Reimplemented from lib.nodes.interface._BaseNode.

◆ run()

def lib.nodes.sequence.Sequence.run (   self)
Runs the node -- This executes the task

◆ seq() [1/2]

def lib.nodes.sequence.Sequence.seq (   self)

Retrieves the sequence list.

   :meta private:

◆ seq() [2/2]

def lib.nodes.sequence.Sequence.seq (   self,
  s 
)

List used to create the Sequence's graph.

   Parameters
   -----------

s Sequence list.

Members of 's' represents sequence nodes. If they are coroutines
they are automagically converted to :class:'Action' nodes.

◆ start()

def lib.nodes.sequence.Sequence.start (   self,
  make_sequence = True,
  resume = False 
)

This is the entry point for Sequence execution.

Returns
Returns the :class:SeqTask object that executes the sequence
Exceptions
ExceptionAny exception received is re-raised and the sequence is aborted.

◆ start_node()

def lib.nodes.sequence.Sequence.start_node (   self)

Returns the start node.

   If it does not exist, it creates it.

Reimplemented from lib.nodes.interface._BaseNode.

◆ start_step()

def lib.nodes.sequence.Sequence.start_step (   self)
Standard sequence's start step.

Sets the sequence's state to RUNNING

◆ state() [1/3]

def lib.nodes.sequence.Sequence.state (   self)

Gets the node state.

Reimplemented from lib.nodes.interface._BaseNode.

◆ state() [2/3]

def lib.nodes.sequence.Sequence.state (   self,
  value 
)

Sets the node state.

Reimplemented from lib.nodes.interface._BaseNode.

◆ state() [3/3]

def lib.nodes.sequence.Sequence.state (   self,
  value 
)

Sets the node state.

Reimplemented from lib.nodes.interface._BaseNode.

Member Data Documentation

◆ current_tpl

lib.nodes.sequence.Sequence.current_tpl = cv.ContextVar("current_tpl", default=None)
static

◆ debug

lib.nodes.sequence.Sequence.debug = attr.ib(init=False, default=False, repr=False)
static

◆ exception

lib.nodes.sequence.Sequence.exception

◆ graph

lib.nodes.sequence.Sequence.graph = attr.ib(init=False, default=attr.Factory(nx.DiGraph), repr=False)
static

◆ id

lib.nodes.sequence.Sequence.id

◆ in_error

lib.nodes.sequence.Sequence.in_error

◆ name

lib.nodes.sequence.Sequence.name

◆ root

lib.nodes.sequence.Sequence.root = cv.ContextVar("root", default=None)
static

◆ runtime_flags

lib.nodes.sequence.Sequence.runtime_flags

◆ serial_number

lib.nodes.sequence.Sequence.serial_number

◆ skip

lib.nodes.sequence.Sequence.skip

◆ state

lib.nodes.sequence.Sequence.state

node state

◆ t_end

lib.nodes.sequence.Sequence.t_end

◆ t_start

lib.nodes.sequence.Sequence.t_start

The documentation for this class was generated from the following file:
a.a
def a()
Definition: a.py:14