recipe.definition package

Submodules

recipe.definition.connection module

Defines the classes for representing a connection between two interface parameters within a recipe definition

class recipe.definition.connection.DependencyInputConnection(input_name, node_name, output_name)

Bases: recipe.definition.connection.InputConnection

Represents a connection from one node’s output to another node’s input

add_parameter_to_interface(interface, recipe_input_interface, node_output_interfaces)

See recipe.definition.connection.InputConnection.add_parameter_to_interface()

add_value_to_data(data, recipe_input_data, node_outputs)

See recipe.definition.connection.InputConnection.add_value_to_data()

is_equal_to(connection)

See recipe.definition.connection.InputConnection.is_equal_to()

validate(all_dependencies)

See recipe.definition.connection.InputConnection.validate()

class recipe.definition.connection.InputConnection(input_name)

Bases: object

Abstract base class that represents a connection between two interface parameters

add_parameter_to_interface(interface, recipe_input_interface, node_output_interfaces)

Adds the parameter for this connection to the interface

Parameters:
Returns:

A list of warnings discovered during validation

Return type:

list()

:raises data.interface.exceptions.InvalidInterfaceConnection: If the interface connection is invalid

add_value_to_data(data, recipe_input_data, node_outputs)

Adds the value for this connection to the data

Parameters:
  • data (data.data.data.Data) – The data to add the value to
  • recipe_input_data (data.data.data.Data) – The input data for the recipe
  • node_outputs (dict) – The RecipeNodeOutput tuples stored in a dict by node name

:raises data.data.exceptions.InvalidData: If there is a duplicate data value

is_equal_to(connection)

Returns true if and only if the given input connection is equal to this one

Parameters:connection (recipe.definition.connection.InputConnection) – The input connection
Returns:True if the connections are equal, False otherwise
Return type:bool
validate(all_dependencies)

Validates this connection

Parameters:all_dependencies (set) – A set of all dependencies (node names) for the input node
Returns:A list of warnings discovered during validation
Return type:list()

:raises data.interface.exceptions.InvalidInterfaceConnection: If the interface connection is invalid

class recipe.definition.connection.RecipeInputConnection(input_name, recipe_input_name)

Bases: recipe.definition.connection.InputConnection

Represents a connection from the recipe’s input to a node’s input

add_parameter_to_interface(interface, recipe_input_interface, node_output_interfaces)

See recipe.definition.connection.InputConnection.add_parameter_to_interface()

add_value_to_data(data, recipe_input_data, node_outputs)

See recipe.definition.connection.InputConnection.add_value_to_data()

is_equal_to(connection)

See recipe.definition.connection.InputConnection.is_equal_to()

validate(all_dependencies)

See recipe.definition.connection.InputConnection.validate()

recipe.definition.definition module

Defines the class for representing a recipe definition

class recipe.definition.definition.RecipeDefinition(input_interface)

Bases: object

Represents a recipe definition, which consists of an input interface and a directed acyclic graph of recipe nodes

add_condition_node(name, input_interface, data_filter)

Adds a condition node to the recipe graph

Parameters:

:raises recipe.definition.exceptions.InvalidDefinition: If the node is duplicated

add_dependency(parent_name, child_name, acceptance=True)

Adds a dependency that one node has upon another node

Parameters:
  • parent_name (string) – The name of the parent node
  • child_name (string) – The name of the child node
  • acceptance (bool) – Whether the child node should run when the parent is accepted or when it is not accepted

:raises recipe.definition.exceptions.InvalidDefinition: If either node is unknown

add_dependency_input_connection(node_name, node_input_name, dependency_name, dependency_output_name)

Adds a connection from a dependency output to the input of a node

Parameters:
  • node_name (string) – The name of the node whose input is being connected to
  • node_input_name (string) – The name of the node’s input
  • dependency_name (string) – The name of the dependency node whose output is being connected to the input
  • dependency_output_name (string) – The name of the dependency node’s output
:raises recipe.definition.exceptions.InvalidDefinition: If either node is unknown, the dependency node
is the wrong type, or the connection is a duplicate
add_job_node(name, job_type_name, job_type_version, revision_num)

Adds a job node to the recipe graph

Parameters:
  • name (string) – The node name
  • job_type_name (string) – The name of the job type
  • job_type_version (string) – The version of the job type
  • revision_num (int) – The revision number of the job type

:raises recipe.definition.exceptions.InvalidDefinition: If the node is duplicated

add_recipe_input_connection(node_name, node_input_name, recipe_input_name)

Adds a connection from a recipe input to the input of a node

Parameters:
  • node_name (string) – The name of the node whose input is being connected to
  • node_input_name (string) – The name of the node’s input
  • recipe_input_name (string) – The name of the recipe input being connected to the node’s input
:raises recipe.definition.exceptions.InvalidDefinition: If the node or recipe input is unknown or the
connection is a duplicate
add_recipe_node(name, recipe_type_name, revision_num)

Adds a recipe node to the recipe graph

Parameters:
  • name (string) – The node name
  • recipe_type_name (string) – The name of the recipe type
  • revision_num (int) – The revision number of the recipe type

:raises recipe.definition.exceptions.InvalidDefinition: If the node is duplicated

generate_node_input_data(node_name, recipe_input_data, node_outputs, optional_outputs=None)

Generates the input data for the node with the given name

Parameters:
  • node_name (string) – The name of the node
  • recipe_input_data (data.data.data.Data) – The input data for the recipe
  • node_outputs (dict) – The RecipeNodeOutput tuples stored in a dict by node name
Returns:

The input data for the node

Return type:

data.data.data.Data

:raises data.data.exceptions.InvalidData: If there is a duplicate data value

get_input_keys()

Returns the input keys to this recipe

get_job_nodes(job_type_name, job_type_version)

Gets the nodes for the given job type contained in this RecipeDefinition, if any

Parameters:
  • job_type_name (string) – The name of the job type
  • job_type_version (string) – The version of the job type
Returns:

list of JobNodeDefinition objects

Return type:

list[recipe.definition.node.JobNodeDefinition]

get_job_type_keys()

Gets the natural keys of the job types contained in this RecipeDefinition

Returns:set of JobTypeKey tuples
Return type:set[job.models.JobTypeKey]
get_recipe_nodes(recipe_type_name)

Gets the nodes for the given recipe type contained in this RecipeDefinition, if any

Parameters:recipe_type_name (string) – The name of the recipe type
Returns:list of RecipeNodeDefinition objects
Return type:list[recipe.definition.node.RecipeNodeDefinition]
get_recipe_type_names()

Gets the names of the sub recipe types contained in this RecipeDefinition

Returns:set of RecipeType names
Return type:set[string]
get_topological_order()

Returns the recipe node names in a valid topological ordering (dependency order)

Returns:The list of nodes names in a topological ordering
Return type:list()
:raises recipe.definition.exceptions.InvalidDefinition: If the definition contains a circular
dependency
has_ancestor(child, ancestor)

Returns if the child node contains ancestor as a parent/grand parent/etc

has_descendant(parent, descendant)

Returns if the parent node contains descendant_node as a child/grand child/etc

update_job_nodes(job_type_name, job_type_version, revision_num)

Updates the revision of job nodes with the given name and version

Parameters:
  • job_type_name (string) – The name of the job type
  • job_type_version (string) – The version of the job type
  • revision_num (int) – The new revision number of the job type
Returns:

True if a node was updated, otherwise false

Return type:

bool

update_recipe_nodes(recipe_type_name, revision_num)

Updates the revision of recipe nodes with the given name to the specified revision_num

Parameters:
  • recipe_type_name (string) – The name of the recipe type
  • revision_num (int) – The new revision number of the recipe type
Returns:

True if a node was updated, otherwise false

Return type:

bool

validate(node_input_interfaces, node_output_interfaces)

Validates this recipe definition

Parameters:
  • node_input_interfaces (dict) – The input interface for each job/recipe node stored by node name
  • node_output_interfaces (dict) – The output interface for each job node stored by node name
Returns:

A list of warnings discovered during validation

Return type:

list()

:raises recipe.definition.exceptions.InvalidDefinition: If the definition is invalid

validate_job_interfaces()

Placeholder so v5 job types can validate with v6 recipe definitions. V6 definitions are tied to a specific job type revision so a v5 edit cannot cause incompatibility. The recipe definition needs to be updated manually to use the new revision and connections will be tested then.

recipe.definition.exceptions module

Defines exceptions that can occur when interacting with recipe definitions

exception recipe.definition.exceptions.InvalidDefinition(name, description)

Bases: util.exceptions.ValidationException

Exception indicating that the provided recipe definition was invalid

recipe.definition.node module

Defines the classes for representing nodes within a recipe definition

class recipe.definition.node.ConditionNodeDefinition(name, input_interface, data_filter)

Bases: recipe.definition.node.NodeDefinition

Represents a condition within a recipe definition

NODE_TYPE = u'condition'
class recipe.definition.node.JobNodeDefinition(name, job_type_name, job_type_version, revision_num)

Bases: recipe.definition.node.NodeDefinition

Represents a job within a recipe definition

NODE_TYPE = u'job'
class recipe.definition.node.NodeDefinition(name, node_type)

Bases: object

Represents a node within a recipe definition

add_connection(connection)

Adds a connection that connects a parameter to one of this node’s inputs

Parameters:connection (recipe.definition.connection.InputConnection) – The connection to add

:raises recipe.definition.exceptions.InvalidDefinition: If the definition is invalid

add_dependency(node, acceptance=True)

Adds a dependency that this node has on the given node

Parameters:
generate_input_data(recipe_input_data, node_outputs, optional_outputs)

Generates the input data for this node

Parameters:
  • recipe_input_data (data.data.data.Data) – The input data for the recipe
  • node_outputs (dict) – The RecipeNodeOutput tuples stored in a dict by node name
Returns:

The input data for this node

Return type:

data.data.data.Data

:raises data.data.exceptions.InvalidData: If there is a duplicate data value

validate(recipe_input_interface, node_input_interfaces, node_output_interfaces)

Validates this node

Parameters:
  • recipe_input_interface (data.interface.interface.Interface) – The interface for the recipe input
  • node_input_interfaces (dict) – The input interface for each node stored by node name
  • node_output_interfaces (dict) – The output interface for each node stored by node name
Returns:

A list of warnings discovered during validation

Return type:

list()

:raises recipe.definition.exceptions.InvalidDefinition: If the definition is invalid

class recipe.definition.node.RecipeNodeDefinition(name, recipe_type_name, revision_num)

Bases: recipe.definition.node.NodeDefinition

Represents a recipe within a recipe definition

NODE_TYPE = u'recipe'

Module contents