mrv.dgfe

Epydoc: mrv.dgfe

Contains nodes supporting facading within a dependency graph - this can be used for container tyoes or nodes containing their own subgraph even

Classes

Epydoc: mrv.dgfe

class mrv.dgfe.Attribute(typeClass, flags, default=None)

Bases: object

Simple class defining the type of a plug and several flags that affect it. Additionally it can determine how well suited another attribute is

Flags:
exact_type: if True, derived classes of our typecls are not considered to be a valid type. i.e: basestring could be stored in a str attr if exact type is false - its less than we need, but still something. Putting a str into a basestring attribute will always work though, as it would be more than we need readonly: if True, the attribute’s plug cannot be written to. Read-only attributes can be used as storage that the user can read, but not write. You can write read-only plugs by directly setting its cache - this of course - is only for the node itself, but will never be done by the framework
computable:

Nodes are automatically computable if they are affected by another plug. If this is not the case, they are marked input only and are not computed. If this flag is true, even unaffeted plugs are computable. Plugs that affect something are automatically input plugs and will not be computed. If the plug does not affect anything and this flag is False, they are seen as input plugs anyway.

The system does not allow plugs to be input and output plugs at the same time, thus your compute cannot be triggered by your own compute

cls: if True, the plug requires classes to be set ( instances of ‘type’ ) , but no instances of these classes uncached: if False, computed values may be cached, otherwise they will always be recomputed. unconnectable: if True, the node cannot be the destination of a connection check_passing_values: check each value as it flows through a connection - usually compatability is only checked on connection and once values are set, but not if they flow through an existing connection

Default Values:
Although default values can be simple primitives are classes, a callable is specifically supported. It allows you to get a callback whenever a default value is required. The same result could be achieved by connected the plug in question, but dynamic defaults are a quick way to achive that. Your returned value will be type-checked against the required type if check_passing_values is set.
affinity(otherattr)

Compute affinity for otherattr.

Returns:rating from 0 to 255 defining how good the attribtues match each other in general - how good can we store values of otherattr ? Thus this comparison is directed.
Note:for checking connections, use connectionAffinity
compatabilityRate(value)

Compute value’s compatability rate

Returns:value between 0 and 255, 0 means no compatability, 255 a perfect match. if larger than 0, the plug can hold the value ( assumed the flags are set correctly ).
connectionAffinity(destinationattr)

Compute connection affinity for given destination attribute

Returns:rating from 0 to 255 defining the quality of the connection to otherplug. an affinity of 0 mean connection is not possible, 255 mean the connection is perfectly suited. The connection is a directed one from self -> otherplug
default()
Returns:default value stored for this attribute, or raise
Note:handles dynamic defaults, so you should not directly access the default member variable
Raises MissingDefaultValueError:
 if attribute does not have a default value
Raises TypeError:
 if value returned by dynamic attribute has incorrect type

Epydoc: mrv.dgfe

class mrv.dgfe.DiGraph(data=None, name='', **attr)

Bases: networkx.classes.graph.Graph

add_cycle(nlist, **attr)
add_edge(u, v, attr_dict=None, **attr)
add_edges_from(ebunch, attr_dict=None, **attr)
add_node(n, attr_dict=None, **attr)
add_nodes_from(nodes, **attr)
add_path(nlist, **attr)
add_star(nlist, **attr)
add_weighted_edges_from(ebunch, **attr)
adjacency_iter()
adjacency_list()
clear()
copy()
degree(nbunch=None, with_labels=False, weighted=False)
degree_iter(nbunch=None, weighted=False)
edges(nbunch=None, data=False)
edges_iter(nbunch=None, data=False)
get_edge_data(u, v, default=None)
has_edge(u, v)
has_node(n)
has_predecessor(u, v)
has_successor(u, v)
in_degree(nbunch=None, with_labels=False, weighted=False)
in_degree_iter(nbunch=None, weighted=False)
in_edges(nbunch=None, data=False)
in_edges_iter(nbunch=None, data=False)
is_directed()
is_multigraph()
nbunch_iter(nbunch=None)
neighbors(n)
neighbors_iter(n)
nodes(data=False)
nodes_iter(data=False)
nodes_with_selfloops()
number_of_edges(u=None, v=None)
number_of_nodes()
number_of_selfloops()
order()
out_degree(nbunch=None, with_labels=False, weighted=False)
out_degree_iter(nbunch=None, weighted=False)
out_edges(nbunch=None, data=False)
out_edges_iter(nbunch=None, data=False)
predecessors(n)
predecessors_iter(n)
remove_edge(u, v)
remove_edges_from(ebunch)
remove_node(n)
remove_nodes_from(nbunch)
reverse(copy=True)
selfloop_edges(data=False)
size(weighted=False)
subgraph(nbunch, copy=True)
successors(n)
successors_iter(n)
to_directed()
to_undirected()

Epydoc: mrv.dgfe.FacadeNodeBase

class mrv.dgfe.FacadeNodeBase(*args, **kwargs)

Bases: mrv.dge.NodeBase

Node having no own plugs, but retrieves them by querying other other nodes and claiming its his own ones.

Using a non-default shell it is possibly to guide all calls through to the virtual PlugShell.

Derived classes must override _plugshells which will be queried when plugs or plugshells are requested. This node will cache the result and do everything required to integrate itself.

It lies in the nature of this class that the plugs are dependent on a specific instance of this node, thus classmethods of NodeBase have been overridden with instance versions of it.

The facade node keeps a plug map allowing it to map plug-shells it got from you back to the original shell respectively. If the map has been missed, your node will be asked for information.

Note:facades are intrusive for the nodes they are facading - thus the nodes returned by _getNodePlugs will be altered. Namely the instance will get a shellcls and plug override to allow us to hook into the callchain. Thus you should have your own instance of the node - otherwise things might behave differently for others using your nodes from another angle
Note:this class could also be used for facades Container nodes that provide an interface to their internal nodes
classmethod addSep(item, sep)
Returns:

item with separator added to it ( just once )

Note:

operates best on strings

Parameters:
  • item – item to add separator to
  • sep – the separator
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
children(predicate=<function <lambda> at 0x7f41dd7c2ed8>)
Returns:list of intermediate children of path, [ child1 , child2 ]
Parameter:predicate – return True to include x in result
Note:the child objects returned are supposed to be valid paths, not just relative paths
childrenDeep(order=1, predicate=<function <lambda> at 0x7f41dd7c5050>)
Returns:

list of all children of path, [ child1 , child2 ]

Parameters:
  • order – order enumeration
  • predicate – returns true if x may be returned
Note:

the child objects returned are supposed to be valid paths, not just relative paths

clearCache()
Clear the cache of all plugs on this node - this basically forces it to recompute the next time an output plug is being queried
clearPlugCache()

if a cache has been build as caching is enabled, this method clears the cache forcing it to be updated on the next demand

Note:this could be more efficient by just deleting plugs that are not required anymore, but probably this method can expect the whole cache to be deleted right away ... so its fine
compute(plug, mode)

Called whenever a plug needs computation as the value its value is not cached or marked dirty ( as one of the inputs changed )

Parameters:
  • plug – the static plug instance that requested which requested the computation. It is the instance you defined on the class
  • mode – the mode of operation. Its completely up to the superclasses how that attribute is going to be used
Note:

to be implemented by superclass

connections(inpt, output)
Returns:

Tuples of input shells defining a connection of the given type from tuple( InputNodeOuptutShell, OurNodeInputShell ) for input connections and tuple( OurNodeOuptutShell, OutputNodeInputShell )

Parameters:
  • inpt – include input connections to this node
  • output – include output connections ( from this node to others )
copyFrom(other, **kwargs)
Actually, it does nothing because our plugs are linked to the internal nodes in a quite complex way. The good thing is that this is just a cache that will be updated once someone queries connections again. Basically it comes down to the graph duplicating itself using node and plug methods instead of just doing his ‘internal’ magic
copyTo(instance, *args, **kwargs)

Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance

Returns:altered instance
Note:instance will be altered during the process
copyToOther(instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo
createInstance(*args, **kwargs)

Create a copy of self and return it

Note:override by subclass - the __init__ methods shuld do the rest
duplicate(*args, **kwargs)

Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method. Thus we will call the method directly on the class

Parameters:
  • args – passed to copyFrom and createInstance method to give additional directions
  • kwargs – see param args
classmethod filterCompatiblePlugs(plugs, attrOrValue, raise_on_ambiguity=False, attr_affinity=False, attr_as_source=True)
Returns:

sorted list of (rate,plug) tuples suitable to deal with the given attribute. Thus they could connect to it as well as get their value set. Most suitable plug comes first. Incompatible plugs will be pruned.

Parameters:
  • attrOrValue – either an attribute or the value you would like to set to the attr at the plug in question.
  • raise_on_ambiguity – if True, the method raises if a plug has the same rating as another plug already on the output list, thus it’s not clear anymore which plug should handle a request
  • attr_affinity – if True, it will not check connection affinity, but attribute affinity only. It checks how compatible the attributes of the plugs are, disregarding whether they can be connected or not Only valid if attrOrValue is an attribute
  • attr_as_source – if True, attrOrValue will be treated as the source of a connection or each plug would need to take its values. if False, attrOrValue is the destination of a connection and it needs to take values of the given plugs or they would connect to it. Only used if attrOrValue is an attribute.
Raises TypeError:
 

if ambiguous input was found

fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
id()
Returns:ID of this instance
inputPlugs(**kwargs)
Returns:list of plugs suitable as input
Note:convenience method
classmethod inputPlugsStatic(**kwargs)
Returns:list of static plugs suitable as input
Note:convenience method
isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
isRoot()
Returns:True if this path is the root of the DAG
isRootOf(other)
Returns:True other starts with self
Note:operates on strings
Note:we assume other has the same type as self, thus the same separator
iterParents(predicate=<function <lambda> at 0x7f41dd7c5230>)
Returns:generator retrieving all parents up to the root
Parameter:predicate – returns True for all x that you want to be returned
outputPlugs(**kwargs)
Returns:list of plugs suitable to deliver output
Note:convenience method
classmethod outputPlugsStatic(**kwargs)
Returns:list of static plugs suitable to deliver output
Note:convenience method
parent()
Returns:parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
plugs(**kwargs)
Calls _getNodePlugs method to ask you to actuallly return your actual nodes and plugs or shells. We prepare the returned value to assure we are being called in certain occasion, which actually glues outside and inside worlds together
classmethod plugsStatic(predicate=<function <lambda> at 0x2ed1578>)
Returns:list of static plugs as defined on this node - they are class members
Parameter:predicate – return static plug only if predicate is true
Note:Use this method only if you do not have an instance - there are nodes that actually have no static plug information, but will dynamically generate them. For this to work, they need an instance - thus the plugs method is an instance method and is meant to be the most commonly used one.
root()
Returns:the root of the DAG - it has no further parents
setID(newID)
Set id of this node to newiD :return: previously assigned id
shellcls
alias of _OIShell
supports(interface_type)
Returns:True if this instance supports the interface of the given type
Parameter:interface_type – Type of the interface you require this instance to support
Note:Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work
toShell(plug)
Returns:a plugshell as suitable to for this class
toShells(plugs)
Returns:list of shells made from plugs and our node

Epydoc: mrv.dgfe.GraphNodeBase

class mrv.dgfe.GraphNodeBase(wrappedGraph, *args, **kwargs)

Bases: mrv.dgfe.FacadeNodeBase

A node wrapping a graph, allowing it to be nested within the node All inputs and outputs on this node are purely virtual, thus they internally connect to the wrapped graph.

Todo:tests deletion of graphnodes and see whether they are being garbage collected. It should work with the new collector as it can handle cyclic references - these strong cycles we have a lot in this structure. Weakrefs will not work for nested facade nodes as they are tuples not allowing weak refs.
classmethod addSep(item, sep)
Returns:

item with separator added to it ( just once )

Note:

operates best on strings

Parameters:
  • item – item to add separator to
  • sep – the separator
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
children(predicate=<function <lambda> at 0x7f41dd7c2ed8>)
Returns:list of intermediate children of path, [ child1 , child2 ]
Parameter:predicate – return True to include x in result
Note:the child objects returned are supposed to be valid paths, not just relative paths
childrenDeep(order=1, predicate=<function <lambda> at 0x7f41dd7c5050>)
Returns:

list of all children of path, [ child1 , child2 ]

Parameters:
  • order – order enumeration
  • predicate – returns true if x may be returned
Note:

the child objects returned are supposed to be valid paths, not just relative paths

clearCache()
Clear the cache of all plugs on this node - this basically forces it to recompute the next time an output plug is being queried
clearPlugCache()

if a cache has been build as caching is enabled, this method clears the cache forcing it to be updated on the next demand

Note:this could be more efficient by just deleting plugs that are not required anymore, but probably this method can expect the whole cache to be deleted right away ... so its fine
compute(plug, mode)

Called whenever a plug needs computation as the value its value is not cached or marked dirty ( as one of the inputs changed )

Parameters:
  • plug – the static plug instance that requested which requested the computation. It is the instance you defined on the class
  • mode – the mode of operation. Its completely up to the superclasses how that attribute is going to be used
Note:

to be implemented by superclass

connections(inpt, output)
Returns:

Tuples of input shells defining a connection of the given type from tuple( InputNodeOuptutShell, OurNodeInputShell ) for input connections and tuple( OurNodeOuptutShell, OutputNodeInputShell )

Parameters:
  • inpt – include input connections to this node
  • output – include output connections ( from this node to others )
copyFrom(other, **kwargs)
Actually, it does nothing because our plugs are linked to the internal nodes in a quite complex way. The good thing is that this is just a cache that will be updated once someone queries connections again. Basically it comes down to the graph duplicating itself using node and plug methods instead of just doing his ‘internal’ magic
copyTo(instance, *args, **kwargs)

Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance

Returns:altered instance
Note:instance will be altered during the process
copyToOther(instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo
createInstance(**kwargs)
Create a copy of self and return it
duplicate(*args, **kwargs)

Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method. Thus we will call the method directly on the class

Parameters:
  • args – passed to copyFrom and createInstance method to give additional directions
  • kwargs – see param args
classmethod filterCompatiblePlugs(plugs, attrOrValue, raise_on_ambiguity=False, attr_affinity=False, attr_as_source=True)
Returns:

sorted list of (rate,plug) tuples suitable to deal with the given attribute. Thus they could connect to it as well as get their value set. Most suitable plug comes first. Incompatible plugs will be pruned.

Parameters:
  • attrOrValue – either an attribute or the value you would like to set to the attr at the plug in question.
  • raise_on_ambiguity – if True, the method raises if a plug has the same rating as another plug already on the output list, thus it’s not clear anymore which plug should handle a request
  • attr_affinity – if True, it will not check connection affinity, but attribute affinity only. It checks how compatible the attributes of the plugs are, disregarding whether they can be connected or not Only valid if attrOrValue is an attribute
  • attr_as_source – if True, attrOrValue will be treated as the source of a connection or each plug would need to take its values. if False, attrOrValue is the destination of a connection and it needs to take values of the given plugs or they would connect to it. Only used if attrOrValue is an attribute.
Raises TypeError:
 

if ambiguous input was found

fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
id()
Returns:ID of this instance
inputPlugs(**kwargs)
Returns:list of plugs suitable as input
Note:convenience method
classmethod inputPlugsStatic(**kwargs)
Returns:list of static plugs suitable as input
Note:convenience method
isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
isRoot()
Returns:True if this path is the root of the DAG
isRootOf(other)
Returns:True other starts with self
Note:operates on strings
Note:we assume other has the same type as self, thus the same separator
iterParents(predicate=<function <lambda> at 0x7f41dd7c5230>)
Returns:generator retrieving all parents up to the root
Parameter:predicate – returns True for all x that you want to be returned
outputPlugs(**kwargs)
Returns:list of plugs suitable to deliver output
Note:convenience method
classmethod outputPlugsStatic(**kwargs)
Returns:list of static plugs suitable to deliver output
Note:convenience method
parent()
Returns:parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
plugs(**kwargs)
Calls _getNodePlugs method to ask you to actuallly return your actual nodes and plugs or shells. We prepare the returned value to assure we are being called in certain occasion, which actually glues outside and inside worlds together
classmethod plugsStatic(predicate=<function <lambda> at 0x2ed1578>)
Returns:list of static plugs as defined on this node - they are class members
Parameter:predicate – return static plug only if predicate is true
Note:Use this method only if you do not have an instance - there are nodes that actually have no static plug information, but will dynamically generate them. For this to work, they need an instance - thus the plugs method is an instance method and is meant to be the most commonly used one.
root()
Returns:the root of the DAG - it has no further parents
setID(newID)
Set id of this node to newiD :return: previously assigned id
shellcls
alias of _OIShell
supports(interface_type)
Returns:True if this instance supports the interface of the given type
Parameter:interface_type – Type of the interface you require this instance to support
Note:Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work
toShell(plug)
Returns:a plugshell as suitable to for this class
toShells(plugs)
Returns:list of shells made from plugs and our node

Epydoc: mrv.dgfe

class mrv.dgfe.NodeBase(*args, **kwargs)

Bases: mrv.interface.iDuplicatable

Base class that provides support for plugs to the superclass. It will create some simple tracking attriubtes required for the plug system to work

Nodes can compute values of their plugs if these do not have a cache.

Nodes are identified by an ID - the default graph implementation though will be okay with just having instances. It is also being used for string representations of this node

classmethod addSep(item, sep)
Returns:

item with separator added to it ( just once )

Note:

operates best on strings

Parameters:
  • item – item to add separator to
  • sep – the separator
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
children(predicate=<function <lambda> at 0x7f41dd7c2ed8>)
Returns:list of intermediate children of path, [ child1 , child2 ]
Parameter:predicate – return True to include x in result
Note:the child objects returned are supposed to be valid paths, not just relative paths
childrenDeep(order=1, predicate=<function <lambda> at 0x7f41dd7c5050>)
Returns:

list of all children of path, [ child1 , child2 ]

Parameters:
  • order – order enumeration
  • predicate – returns true if x may be returned
Note:

the child objects returned are supposed to be valid paths, not just relative paths

clearCache()
Clear the cache of all plugs on this node - this basically forces it to recompute the next time an output plug is being queried
compute(plug, mode)

Called whenever a plug needs computation as the value its value is not cached or marked dirty ( as one of the inputs changed )

Parameters:
  • plug – the static plug instance that requested which requested the computation. It is the instance you defined on the class
  • mode – the mode of operation. Its completely up to the superclasses how that attribute is going to be used
Note:

to be implemented by superclass

connections(inpt, output)
Returns:

Tuples of input shells defining a connection of the given type from tuple( InputNodeOuptutShell, OurNodeInputShell ) for input connections and tuple( OurNodeOuptutShell, OutputNodeInputShell )

Parameters:
  • inpt – include input connections to this node
  • output – include output connections ( from this node to others )
copyFrom(other, add_to_graph=True)

Just take the graph from other, but do not ( never ) duplicate it

Parameter:add_to_graph – if true, the new node instance will be added to the graph of
Note:default implementation does not copy plug caches ( which are stored in the node dict - this is because a reevaluate is usually required on the duplicated node
copyTo(instance, *args, **kwargs)

Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance

Returns:altered instance
Note:instance will be altered during the process
copyToOther(instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo
createInstance(*args, **kwargs)

Create a copy of self and return it

Note:override by subclass - the __init__ methods shuld do the rest
duplicate(*args, **kwargs)

Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method. Thus we will call the method directly on the class

Parameters:
  • args – passed to copyFrom and createInstance method to give additional directions
  • kwargs – see param args
classmethod filterCompatiblePlugs(plugs, attrOrValue, raise_on_ambiguity=False, attr_affinity=False, attr_as_source=True)
Returns:

sorted list of (rate,plug) tuples suitable to deal with the given attribute. Thus they could connect to it as well as get their value set. Most suitable plug comes first. Incompatible plugs will be pruned.

Parameters:
  • attrOrValue – either an attribute or the value you would like to set to the attr at the plug in question.
  • raise_on_ambiguity – if True, the method raises if a plug has the same rating as another plug already on the output list, thus it’s not clear anymore which plug should handle a request
  • attr_affinity – if True, it will not check connection affinity, but attribute affinity only. It checks how compatible the attributes of the plugs are, disregarding whether they can be connected or not Only valid if attrOrValue is an attribute
  • attr_as_source – if True, attrOrValue will be treated as the source of a connection or each plug would need to take its values. if False, attrOrValue is the destination of a connection and it needs to take values of the given plugs or they would connect to it. Only used if attrOrValue is an attribute.
Raises TypeError:
 

if ambiguous input was found

fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
id()
Returns:ID of this instance
inputPlugs(**kwargs)
Returns:list of plugs suitable as input
Note:convenience method
classmethod inputPlugsStatic(**kwargs)
Returns:list of static plugs suitable as input
Note:convenience method
isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
isRoot()
Returns:True if this path is the root of the DAG
isRootOf(other)
Returns:True other starts with self
Note:operates on strings
Note:we assume other has the same type as self, thus the same separator
iterParents(predicate=<function <lambda> at 0x7f41dd7c5230>)
Returns:generator retrieving all parents up to the root
Parameter:predicate – returns True for all x that you want to be returned
outputPlugs(**kwargs)
Returns:list of plugs suitable to deliver output
Note:convenience method
classmethod outputPlugsStatic(**kwargs)
Returns:list of static plugs suitable to deliver output
Note:convenience method
parent()
Returns:parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
plugs(predicate=<function <lambda> at 0x2ed1668>)
Returns:list of dynamic plugs as defined on this node - they are usually retrieved on class level, but may be overridden on instance level
Parameter:predicate – return static plug only if predicate is true
classmethod plugsStatic(predicate=<function <lambda> at 0x2ed1578>)
Returns:list of static plugs as defined on this node - they are class members
Parameter:predicate – return static plug only if predicate is true
Note:Use this method only if you do not have an instance - there are nodes that actually have no static plug information, but will dynamically generate them. For this to work, they need an instance - thus the plugs method is an instance method and is meant to be the most commonly used one.
root()
Returns:the root of the DAG - it has no further parents
setID(newID)
Set id of this node to newiD :return: previously assigned id
shellcls
alias of _PlugShell
supports(interface_type)
Returns:True if this instance supports the interface of the given type
Parameter:interface_type – Type of the interface you require this instance to support
Note:Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work
toShell(plug)
Returns:a plugshell as suitable to for this class
toShells(plugs)
Returns:list of shells made from plugs and our node

Epydoc: mrv.dgfe.OIFacadePlug

class mrv.dgfe.OIFacadePlug

Bases: tuple, mrv.dge.iPlug

Facade Plugs are meant to be stored on instance level overriding the respective class level plug descriptor. If used directly, it will facade the internal affects relationships and just return what really is affected on the facade node

Additionally they are associated to a node instance, and can thus be used to find the original node once the plug is used in an OI facacde shell

Its a tuple as it will be more memory efficient that way. Additionally one automatically has a proper hash and comparison if the same objects come together

affected()

Walk the internal affects using an internal plugshell

Note:only output plugs can be affected - this is a rule followed throughout the system
Returns:tuple containing affected plugs ( plugs that are affected by our value )
affectedBy()
Walk the graph upwards and return all input plugs that are being facaded :return: tuple containing plugs that affect us ( plugs affecting our value )
affects(otherplug)
Affects relationships will be set on the original plug only
count
T.count(value) -> integer – return number of occurrences of value
index
T.index(value, [start, [stop]]) -> integer – return first index of value. Raises ValueError if the value is not present.
name()

Get name of facade plug

Returns:name of (internal) plug - must be a unique key, unique enough to allow connections to several nodes of the same type
providesInput()
Returns:True if this is an input plug that will never cause computations
providesOutput()
Returns:True if this is an output plug that can trigger computations

Epydoc: mrv.dgfe._IOShell

class mrv.dgfe._IOShell(*args)

Bases: mrv.dge._PlugShell

This callable class, when called, will create a IOShell using the actual facade node, not the one given as input. This allows it to have the facade system handle the plugshell, or simply satisfy the original request

cache(*args, **kwargs)
clearCache(*args, **kwargs)
Clear caches of all output plugs as well
compatabilityRate(value)

Compute compatability rate for teh given value

Returns:value between 0 and 255, 0 means no compatability, 255 a perfect match if larger than 0, the plug can hold the value ( assumed the flags are set correctly )
connect(*args, **kwargs)
connections(*args, **kwargs)
count
T.count(value) -> integer – return number of occurrences of value
disconnect(*args, **kwargs)
get(*args, **kwargs)
apply to the input shell
hasCache(*args, **kwargs)
index
T.index(value, [start, [stop]]) -> integer – return first index of value. Raises ValueError if the value is not present.
input(*args, **kwargs)
isConnected()
Returns:True, if the shell is connected as source or as destination of a connection
iterShells(*args, **kwargs)
outputs(*args, **kwargs)
set(*args, **kwargs)
setCache(*args, **kwargs)

Epydoc: mrv.dgfe._IOShellMeta

class mrv.dgfe._IOShellMeta

Bases: mrv.dgfe._OIShellMeta

Metaclass wrapping all unfacade attributes on the plugshell trying to get an input connection

classmethod createFacadeMethod(funcname)
Call the main shell’s function
classmethod createMethod(funcname, facadetype)
classmethod createUnfacadeMethod(funcname)
Returns:wrapper method for funcname
mro
mro() -> list return a type’s method resolution order

Epydoc: mrv.dgfe._OIShell

class mrv.dgfe._OIShell(*args)

Bases: mrv.dge._PlugShell

All connections from and to the FacadeNode must actually start and end there. Iteration over internal plugShells is not allowed. Thus we override only the methods that matter and assure that the call is handed to the acutal internal plugshell. We know everything we require as we have been fed with an oiplug

  • node = facacde node
  • plug = oiplug containing inode and iplug ( internal node and internal plug )
  • The internal node allows us to hand in calls to the native internal shell
cache(*args, **kwargs)
clearCache(*args, **kwargs)
compatabilityRate(value)

Compute compatability rate for teh given value

Returns:value between 0 and 255, 0 means no compatability, 255 a perfect match if larger than 0, the plug can hold the value ( assumed the flags are set correctly )
connect(otherplugshell, **kwargs)

Connect this plug to otherplugshell such that otherplugshell is an input plug for our output

Parameter:kwargs – everything supported by Graph.connect
Returns:self on success, allows chained connections
Raises PlugAlreadyConnected:
 if otherplugshell is connected and force is False
Raises PlugIncompatible:
 if otherplugshell does not appear to be compatible to this one
connections(inpt, output, predicate=<function <lambda> at 0x2ed0050>)
Returns:get all input and or output connections from this shell or to this shell as edges ( sourceshell, destinationshell )
Parameter:predicate – return true for each destination shell that you can except in the returned edge or the sourceshell where your shell is the destination.
Note:Use this method to get edges read for connection/disconnection
count
T.count(value) -> integer – return number of occurrences of value
disconnect(otherplugshell)
Remove the connection to otherplugshell if we are connected to it. :note: does not raise if no connection is present
get(*args, **kwargs)
hasCache(*args, **kwargs)
index
T.index(value, [start, [stop]]) -> integer – return first index of value. Raises ValueError if the value is not present.
input(predicate=<function <lambda> at 0x2ecfde8>)
Returns:the connected input plug or None if there is no such connection
Parameter:predicate – plug will only be returned if predicate is true for it
Note:input plugs have on plug at most, output plugs can have more than one connected plug
isConnected()
Returns:True, if the shell is connected as source or as destination of a connection
iterShells(**kwargs)
Iterate plugs and their connections starting at this plug :return: generator for plug shells :note: supports all options of iterShells, this method allows syntax like: node.outAttribute.iterShells( )
outputs(predicate=<function <lambda> at 0x2ecfed8>)
Returns:a list of plugs being the destination of the connection
Parameter:predicate – plug will only be returned if predicate is true for it - shells will be passed in
set(*args, **kwargs)
setCache(*args, **kwargs)

Epydoc: mrv.dgfe._OIShellMeta

class mrv.dgfe._OIShellMeta

Bases: type

Metaclass building the method wrappers for the _FacadeShell class - not all methods should be overridden, just the ones important to use

classmethod createFacadeMethod(funcname)
in our case, connections just are handled by our own OI plug, staying in the main graph
classmethod createMethod(funcname, facadetype)
classmethod createUnfacadeMethod(funcname)
mro
mro() -> list return a type’s method resolution order

Epydoc: mrv.dgfe

class mrv.dgfe._PlugShell

Bases: tuple

Handles per-node-instance plug connection setup and storage. As plugs are descriptors and thus an instance of the class, per-node-instance information needs special treatment. This class is being returned whenever the descriptors get and set methods are called, it contains information about the node and the plug being involved, allowing to track connection info directly using the node dict

This allows plugs to be connected, and information to flow through the dependency graph. Plugs never act alone since they always belong to a parent node that will be asked for value computations if the value is not yet cached. :note: Do not instantiate this class youself, it must be created by the node as different node types can use different versions of this shell

cache()
Returns:the cached value or raise
Raises ValueError:
 
clearCache(clear_affected=False, cleared_shells_set=None)
Empty the cache of our plug :param clear_affected: if True, the caches of our affected plugs ( connections or affects relations ) will also be cleared This operation is recursive, and needs to be as different shells on different nodes might do things differently. :param cleared_shells_set: if set, it can be used to track which plugs have already been dirtied to prevent recursive loops Propagation will happen even if we do not have a cache to clear ourselves
compatabilityRate(value)

Compute compatability rate for teh given value

Returns:value between 0 and 255, 0 means no compatability, 255 a perfect match if larger than 0, the plug can hold the value ( assumed the flags are set correctly )
connect(otherplugshell, **kwargs)

Connect this plug to otherplugshell such that otherplugshell is an input plug for our output

Parameter:kwargs – everything supported by Graph.connect
Returns:self on success, allows chained connections
Raises PlugAlreadyConnected:
 if otherplugshell is connected and force is False
Raises PlugIncompatible:
 if otherplugshell does not appear to be compatible to this one
connections(inpt, output, predicate=<function <lambda> at 0x2ed0050>)
Returns:get all input and or output connections from this shell or to this shell as edges ( sourceshell, destinationshell )
Parameter:predicate – return true for each destination shell that you can except in the returned edge or the sourceshell where your shell is the destination.
Note:Use this method to get edges read for connection/disconnection
count
T.count(value) -> integer – return number of occurrences of value
disconnect(otherplugshell)
Remove the connection to otherplugshell if we are connected to it. :note: does not raise if no connection is present
get(mode=None)
Returns:value of the plug
Parameter:mode – optional arbitary value specifying the mode of the get attempt
hasCache()
Returns:True if currently store a cached value
index
T.index(value, [start, [stop]]) -> integer – return first index of value. Raises ValueError if the value is not present.
input(predicate=<function <lambda> at 0x2ecfde8>)
Returns:the connected input plug or None if there is no such connection
Parameter:predicate – plug will only be returned if predicate is true for it
Note:input plugs have on plug at most, output plugs can have more than one connected plug
isConnected()
Returns:True, if the shell is connected as source or as destination of a connection
iterShells(**kwargs)
Iterate plugs and their connections starting at this plug :return: generator for plug shells :note: supports all options of iterShells, this method allows syntax like: node.outAttribute.iterShells( )
outputs(predicate=<function <lambda> at 0x2ecfed8>)
Returns:a list of plugs being the destination of the connection
Parameter:predicate – plug will only be returned if predicate is true for it - shells will be passed in
set(value, ignore_connection=False)
Set the given value to be used in our plug :param ignore_connection: if True, the plug can be destination of a connection and will still get its value set - usually it would be overwritten by the value form the connection. The set value will be cleared if something upstream in it’s connection chain changes. :raise AssertionError: the respective attribute must be cached, otherwise the value will be lost
setCache(value)
Set the given value to be stored in our cache :raise: TypeError if the value is not compatible to our defined type

Epydoc: mrv.dgfe

class mrv.dgfe.deque

Bases: object

deque(iterable[, maxlen]) –> deque object

Build an ordered collection accessible from endpoints only.

append
Add an element to the right side of the deque.
appendleft
Add an element to the left side of the deque.
clear
Remove all elements from the deque.
extend
Extend the right side of the deque with elements from the iterable
extendleft
Extend the left side of the deque with elements from the iterable
pop
Remove and return the rightmost element.
popleft
Remove and return the leftmost element.
remove
D.remove(value) – remove first occurrence of value.
rotate
Rotate the deque n steps to the right (default n=1). If n is negative, rotates left.

Epydoc: mrv.dgfe

class mrv.dgfe.iDuplicatable

Bases: mrv.interface.Interface

Simple interface allowing any class to be properly duplicated

Note:to implement this interface, implement createInstance and copyFrom in your class
classmethod addSep(item, sep)
Returns:

item with separator added to it ( just once )

Note:

operates best on strings

Parameters:
  • item – item to add separator to
  • sep – the separator
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
children(predicate=<function <lambda> at 0x7f41dd7c2ed8>)
Returns:list of intermediate children of path, [ child1 , child2 ]
Parameter:predicate – return True to include x in result
Note:the child objects returned are supposed to be valid paths, not just relative paths
childrenDeep(order=1, predicate=<function <lambda> at 0x7f41dd7c5050>)
Returns:

list of all children of path, [ child1 , child2 ]

Parameters:
  • order – order enumeration
  • predicate – returns true if x may be returned
Note:

the child objects returned are supposed to be valid paths, not just relative paths

copyFrom(other, *args, **kwargs)

Copy the data from other into self as good as possible Only copy the data that is unique to your specific class - the data of other classes will be taken care of by them !

Note:you must support args and kwargs if one of your iDuplicate bases does
copyTo(instance, *args, **kwargs)

Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance

Returns:altered instance
Note:instance will be altered during the process
copyToOther(instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo
createInstance(*args, **kwargs)

Create and Initialize an instance of self.__class__( ... ) based on your own data

Returns:new instance of self
Note:using self.__class__ instead of an explicit class allows derived classes that do not have anything to duplicate just to use your implementeation
Note:you must support args and kwargs if one of your iDuplicate bases does
duplicate(*args, **kwargs)

Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method. Thus we will call the method directly on the class

Parameters:
  • args – passed to copyFrom and createInstance method to give additional directions
  • kwargs – see param args
fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
isRoot()
Returns:True if this path is the root of the DAG
isRootOf(other)
Returns:True other starts with self
Note:operates on strings
Note:we assume other has the same type as self, thus the same separator
iterParents(predicate=<function <lambda> at 0x7f41dd7c5230>)
Returns:generator retrieving all parents up to the root
Parameter:predicate – returns True for all x that you want to be returned
parent()
Returns:parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
root()
Returns:the root of the DAG - it has no further parents
supports(interface_type)
Returns:True if this instance supports the interface of the given type
Parameter:interface_type – Type of the interface you require this instance to support
Note:Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work

Epydoc: mrv.dgfe

class mrv.dgfe.iPlug

Bases: object

Defines an interface allowing to compare compatabilies according to types.

Plugs can either be input plugs or output plugs - output plugs affect no other plug on a node, but are affected by 0 or more plugs .

By convention, a plug has a name - that name must also be the name of the member attribute that stores the plag. Plugs, possibly different instances of it, need to be re-retrieved on freshly duplicated nodes to allow graph duplication to be done properly

Note:if your plug class supports the setName method, a metaclass will adjust the name of your plug to match the name it has in the parent class
affected()
Returns:tuple containing affected plugs ( plugs that are affected by our value )
affectedBy()
Returns:tuple containing plugs that affect us ( plugs affecting our value )
affects(otherplug)
Set an affects relation ship between this plug and otherplug, saying that this plug affects otherplug.
name()
Returns:name of the plug ( the name that identifies it on the node
providesInput()
Returns:True if this is an input plug that will never cause computations
providesOutput()
Returns:True if this is an output plug that can trigger computations

Exceptions

Epydoc: mrv.dgfe

class mrv.dgfe.NetworkXError

Bases: networkx.exception.NetworkXException

Exception for a serious error in NetworkX

args
message

Table Of Contents

Previous topic

mrv.exc

Next topic

mrv.batch

This Page