spawn.specification

Specification definition

The SpecificationModel contains the definition of the tasks to be spawned

class spawn.specification.DictSpecificationConverter[source]

Class for converting specification models

Converts SpecificationModel into dict

convert(spec)[source]

Converts the given spec model into a dict

Parameters

spec (SpecificationModel) – The specification model to convert

Returns

A dict represenation of the specification model

Return type

dict

class spawn.specification.Evaluator(*args, name=None)[source]

Evaluator base class implementation of ValueProxy

Implements the evaluate() method of the parent class to expand any arguments

evaluate(**kwargs)[source]

Evaluates the value proxy.

Expands any arguments that are evaluators, and calls the _evaluate() implementation required by base class

class spawn.specification.Macro(value)[source]

Implementation of ValueProxy that can contain a value

evaluate()[source]

Evaluates the Macro - returns the value

Returns

The value contained within the Macro

Return type

object

class spawn.specification.SpecificationMetadata(spec_type, creation_time, notes)[source]

Container class for the SpecificationModel metadata

property creation_time

The creation time

property notes

Notes related to the specification model

property spec_type

The type of this specification

class spawn.specification.SpecificationModel(base_file, root_node, metadata)[source]

Class to contain the description of the spawn specification

property base_file

The base file

property metadata

The metadata

property root_node

The root node

class spawn.specification.SpecificationNode(parent, property_name, property_value, path, ghosts)[source]

Tree node representation of the nodes of the specification

add_child(child)[source]

Adds a child to this node

Parameters

child (SpecificationNode) – The child node to add

property children

Get the children of this node

Returns

Child nodes

Return type

list

property collected_indices

Gets the property names and indicies of this node and all ancestor nodes

Returns

A dict containing the properties of this node and all ancestor nodes

Return type

dict

property collected_properties

Gets the properties and values of this node and all ancestor nodes

Returns

A dict containing the properties of this node and all ancestor nodes

Return type

dict

copy(new_parent)[source]

Copies this node and this node’s children

Parameters

new_parent (SpecificationNode) – The new parent node

Returns

A copy of this node

Return type

SpecificationNode

classmethod create_root(path=None)[source]

Create a root node

Parameters

path (str) – The path for the root node

Returns

A root specification node (without parents)

Return type

SpecificationNode

property description

Description of this node

Returns

A description of the node

Return type

str

evaluate()[source]

Evaluates all children in this node

property ghosts

Returns the collected ghost parameters

Returns

The ghost parameters for this node

Return type

dict

property has_property

Does this node have a property value

Returns

True if this node has a type that contains properties

Return type

bool

property index

Gets the index of this node in the parent’s child nodes

Returns

The index if this node is not a root node; otherwise -1

Return type

int

property is_root

Is this the root node

Returns

True if this node is the root; otherwise False

Return type

bool

property leaves

Gets the leaf nodes descended from this node

Returns

The leaf nodes

Return type

list

property parent

Get the parent

Returns

The parent node

Return type

SpecificationNode

property path

The path for this node.

Used as a key to locate the ouputs. Evaluate using the path property and the collected properties and indices at this node.

Returns

The path for this node

Return type

str

property property_name

Gets the property name for this node

Returns

The property name

Return type

str

property property_value

Gets the property value for this node

Returns

The property value

Return type

object

property root

Gets the root node from this node

Returns

The root node

Return type

SpecificationNode

class spawn.specification.SpecificationNodeFactory[source]

Factory class for creating SpecificationNode objects

create(parent, name, value, path, ghosts, children=None, literal=False)[source]

Creates a SpecificationNode, based on the value

Parameters
  • parent (SpecificationNode) – The parent SpecificationNode

  • name (str) – The name of the node

  • value (object) – The value of the node

  • ghosts (dict) – Ghost values

  • children (list) – The children of the new node, if any

  • literal (bool) – if True, the value is not expandable and is set literally

class spawn.specification.ValueProxy[source]

Base value proxy class

A value proxy is anything that can be evaluate d in place of a value

evaluate()[source]

Evaluates the ValueProxy

Must be implemented in a derived class

Returns

A value

Return type

object

class spawn.specification.ValueProxyNode(parent, name, value_proxy, path, ghosts)[source]

Implementation of SpecificationNode that allows a ValueProxy definition of a node

evaluate()[source]

Evaluates this node to determine what it’s value should be.

Replaces children with new values generated by this node. Subsequently evaluates all children.

spawn.specification.evaluate(value_proxy, *args, **kwargs)[source]

Utility function to evaluate a ValueProxy

Determines whether kwargs needs to be provided

Parameters

value_proxy (VaWlueProxy) – The ValueProxy to evaluate