Contains nodes supporting facading within a dependency graph - this can be used for container tyoes or nodes containing their own subgraph even
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
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
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 |
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 ). |
---|
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 |
---|
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 |
Bases: networkx.classes.graph.Graph
Epydoc: mrv.dgfe.FacadeNodeBase
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 |
Returns: | item with separator added to it ( just once ) |
---|---|
Note: | operates best on strings |
Parameters: |
|
Returns: | basename of this path, ‘/hello/world’ -> ‘world’ |
---|
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 |
Returns: | list of all children of path, [ child1 , child2 ] |
---|---|
Parameters: |
|
Note: | the child objects returned are supposed to be valid paths, not just relative paths |
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 |
---|
Called whenever a plug needs computation as the value its value is not cached or marked dirty ( as one of the inputs changed )
Parameters: |
|
---|---|
Note: | to be implemented by superclass |
Returns: | Tuples of input shells defining a connection of the given type from tuple( InputNodeOuptutShell, OurNodeInputShell ) for input connections and tuple( OurNodeOuptutShell, OutputNodeInputShell ) |
---|---|
Parameters: |
|
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 |
Create a copy of self and return it
Note: | override by subclass - the __init__ methods shuld do the rest |
---|
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: |
|
---|
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: |
|
Raises TypeError: | |
if ambiguous input was found |
Returns: | ID of this instance |
---|
Returns: | list of plugs suitable as input |
---|---|
Note: | convenience method |
Returns: | list of static plugs suitable as input |
---|---|
Note: | convenience method |
Returns: | True if self is a part of other, and thus can be found in other |
---|---|
Note: | operates on strings only |
Returns: | True if this path is the root of the DAG |
---|
Returns: | True other starts with self |
---|---|
Note: | operates on strings |
Note: | we assume other has the same type as self, thus the same separator |
Returns: | generator retrieving all parents up to the root |
---|---|
Parameter: | predicate – returns True for all x that you want to be returned |
Returns: | list of plugs suitable to deliver output |
---|---|
Note: | convenience method |
Returns: | list of static plugs suitable to deliver output |
---|---|
Note: | convenience method |
Returns: | parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root |
---|
Returns: | all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ] |
---|
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. |
Returns: | the root of the DAG - it has no further parents |
---|
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 |
Returns: | a plugshell as suitable to for this class |
---|
Returns: | list of shells made from plugs and our node |
---|
Epydoc: mrv.dgfe.GraphNodeBase
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. |
---|
Returns: | item with separator added to it ( just once ) |
---|---|
Note: | operates best on strings |
Parameters: |
|
Returns: | basename of this path, ‘/hello/world’ -> ‘world’ |
---|
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 |
Returns: | list of all children of path, [ child1 , child2 ] |
---|---|
Parameters: |
|
Note: | the child objects returned are supposed to be valid paths, not just relative paths |
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 |
---|
Called whenever a plug needs computation as the value its value is not cached or marked dirty ( as one of the inputs changed )
Parameters: |
|
---|---|
Note: | to be implemented by superclass |
Returns: | Tuples of input shells defining a connection of the given type from tuple( InputNodeOuptutShell, OurNodeInputShell ) for input connections and tuple( OurNodeOuptutShell, OutputNodeInputShell ) |
---|---|
Parameters: |
|
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 |
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: |
|
---|
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: |
|
Raises TypeError: | |
if ambiguous input was found |
Returns: | ID of this instance |
---|
Returns: | list of plugs suitable as input |
---|---|
Note: | convenience method |
Returns: | list of static plugs suitable as input |
---|---|
Note: | convenience method |
Returns: | True if self is a part of other, and thus can be found in other |
---|---|
Note: | operates on strings only |
Returns: | True if this path is the root of the DAG |
---|
Returns: | True other starts with self |
---|---|
Note: | operates on strings |
Note: | we assume other has the same type as self, thus the same separator |
Returns: | generator retrieving all parents up to the root |
---|---|
Parameter: | predicate – returns True for all x that you want to be returned |
Returns: | list of plugs suitable to deliver output |
---|---|
Note: | convenience method |
Returns: | list of static plugs suitable to deliver output |
---|---|
Note: | convenience method |
Returns: | parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root |
---|
Returns: | all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ] |
---|
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. |
Returns: | the root of the DAG - it has no further parents |
---|
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 |
Returns: | a plugshell as suitable to for this class |
---|
Returns: | list of shells made from plugs and our node |
---|
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
Returns: | item with separator added to it ( just once ) |
---|---|
Note: | operates best on strings |
Parameters: |
|
Returns: | basename of this path, ‘/hello/world’ -> ‘world’ |
---|
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 |
Returns: | list of all children of path, [ child1 , child2 ] |
---|---|
Parameters: |
|
Note: | the child objects returned are supposed to be valid paths, not just relative paths |
Called whenever a plug needs computation as the value its value is not cached or marked dirty ( as one of the inputs changed )
Parameters: |
|
---|---|
Note: | to be implemented by superclass |
Returns: | Tuples of input shells defining a connection of the given type from tuple( InputNodeOuptutShell, OurNodeInputShell ) for input connections and tuple( OurNodeOuptutShell, OutputNodeInputShell ) |
---|---|
Parameters: |
|
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 |
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 |
Create a copy of self and return it
Note: | override by subclass - the __init__ methods shuld do the rest |
---|
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: |
|
---|
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: |
|
Raises TypeError: | |
if ambiguous input was found |
Returns: | ID of this instance |
---|
Returns: | list of plugs suitable as input |
---|---|
Note: | convenience method |
Returns: | list of static plugs suitable as input |
---|---|
Note: | convenience method |
Returns: | True if self is a part of other, and thus can be found in other |
---|---|
Note: | operates on strings only |
Returns: | True if this path is the root of the DAG |
---|
Returns: | True other starts with self |
---|---|
Note: | operates on strings |
Note: | we assume other has the same type as self, thus the same separator |
Returns: | generator retrieving all parents up to the root |
---|---|
Parameter: | predicate – returns True for all x that you want to be returned |
Returns: | list of plugs suitable to deliver output |
---|---|
Note: | convenience method |
Returns: | list of static plugs suitable to deliver output |
---|---|
Note: | convenience method |
Returns: | parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root |
---|
Returns: | all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ] |
---|
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 |
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. |
Returns: | the root of the DAG - it has no further parents |
---|
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 |
Returns: | a plugshell as suitable to for this class |
---|
Returns: | list of shells made from plugs and our node |
---|
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
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 ) |
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 |
---|
Returns: | True if this is an input plug that will never cause computations |
---|
Returns: | True if this is an output plug that can trigger computations |
---|
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
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 ) |
---|
Returns: | True, if the shell is connected as source or as destination of a connection |
---|
Bases: mrv.dgfe._OIShellMeta
Metaclass wrapping all unfacade attributes on the plugshell trying to get an input connection
Returns: | wrapper method for funcname |
---|
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
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 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 |
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 |
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 |
Returns: | True, if the shell is connected as source or as destination of a connection |
---|
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 |
Bases: type
Metaclass building the method wrappers for the _FacadeShell class - not all methods should be overridden, just the ones important to use
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
Returns: | the cached value or raise |
---|---|
Raises ValueError: | |
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 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 |
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 |
Returns: | value of the plug |
---|---|
Parameter: | mode – optional arbitary value specifying the mode of the get attempt |
Returns: | True if currently store a cached value |
---|
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 |
Returns: | True, if the shell is connected as source or as destination of a connection |
---|
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 |
Bases: object
deque(iterable[, maxlen]) –> deque object
Build an ordered collection accessible from endpoints only.
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 |
---|
Returns: | item with separator added to it ( just once ) |
---|---|
Note: | operates best on strings |
Parameters: |
|
Returns: | basename of this path, ‘/hello/world’ -> ‘world’ |
---|
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 |
Returns: | list of all children of path, [ child1 , child2 ] |
---|---|
Parameters: |
|
Note: | the child objects returned are supposed to be valid paths, not just relative paths |
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 |
---|
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 |
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 |
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: |
|
---|
Returns: | True if self is a part of other, and thus can be found in other |
---|---|
Note: | operates on strings only |
Returns: | True if this path is the root of the DAG |
---|
Returns: | True other starts with self |
---|---|
Note: | operates on strings |
Note: | we assume other has the same type as self, thus the same separator |
Returns: | generator retrieving all parents up to the root |
---|---|
Parameter: | predicate – returns True for all x that you want to be returned |
Returns: | parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root |
---|
Returns: | all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ] |
---|
Returns: | the root of the DAG - it has no further parents |
---|
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 |
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 |
---|
Returns: | tuple containing affected plugs ( plugs that are affected by our value ) |
---|
Returns: | tuple containing plugs that affect us ( plugs affecting our value ) |
---|
Returns: | name of the plug ( the name that identifies it on the node |
---|
Returns: | True if this is an input plug that will never cause computations |
---|
Returns: | True if this is an output plug that can trigger computations |
---|