interfaceplugins Package¶
fastrinterface
Module¶
-
class
fastr.resources.plugins.interfaceplugins.fastrinterface.
CollectorPlugin
[source]¶ Bases:
fastr.abc.baseplugin.Plugin
CollectorPlugins
are used for finding and collecting the output data of outputs part of aFastrInterface
-
__abstractmethods__
= frozenset({'_collect_results'})¶
-
__module__
= 'fastr.resources.plugins.interfaceplugins.fastrinterface'¶
-
collect_results
(interface, output, result)[source]¶ Start the collection of the results. This method calls the actual implementation from the subclass (_collect_results) and wraps it with some convience functionality.
Parameters: - interface – Job to collect data for
- output – Output to collect data for
-
fullid
¶ The full id of the plugin
-
-
class
fastr.resources.plugins.interfaceplugins.fastrinterface.
CollectorPluginManager
[source]¶ Bases:
fastr.plugins.managers.pluginmanager.PluginSubManager
Container holding all the CollectorPlugins
-
__abstractmethods__
= frozenset()¶
-
__iter__
()[source]¶ Get an iterator from the BaseManager. The iterator will iterate over the keys of the BaseManager.
Returns: the iterator Return type: dictionary-keyiterator
-
__keytransform__
(key)[source]¶ Identity transform for the keys. This function can be reimplemented by a subclass to implement a different key transform.
Parameters: key – key to transform Returns: the transformed key (in this case the same key as inputted)
-
__module__
= 'fastr.resources.plugins.interfaceplugins.fastrinterface'¶
-
-
class
fastr.resources.plugins.interfaceplugins.fastrinterface.
FastrInterface
(id_, document)[source]¶ Bases:
fastr.core.interface.Interface
The default Interface for fastr. For the command-line Tools as used by fastr. It build a commandline call based on the input/output specification.
The fields that can be set in the interface:
Attribute Description id
The id of this Tool (used internally in fastr) inputs[]
List of Inputs that can are accepted by the Tool id
ID of the Input name
Longer name of the Input (more human readable) datatype
The ID of the DataType of the Input [1] enum[]
List of possible values for an EnumType (created on the fly by fastr) [1] prefix
Commandline prefix of the Input (e.g. –in, -i) cardinality
Cardinality of the Input repeat_prefix
Flag indicating if for every value of the Input the prefix is repeated required
Flag indicating if the input is required nospace
Flag indicating if there is no space between prefix and value (e.g. –in=val) format
For DataTypes that have multiple representations, indicate which one to use default
Default value for the Input description
Long description for an input outputs[]
List of Outputs that are generated by the Tool (and accessible to fastr) id
ID of the Output name
Longer name of the Output (more human readable) datatype
The ID of the DataType of the Output [1] enum[]
List of possible values for an EnumType (created on the fly by fastr) [1] prefix
Commandline prefix of the Output (e.g. –out, -o) cardinality
Cardinality of the Output repeat_prefix
Flag indicating if for every value of the Output the prefix is repeated required
Flag indicating if the input is required nospace
Flag indicating if there is no space between prefix and value (e.g. –out=val) format
For DataTypes that have multiple representations, indicate which one to use description
Long description for an input action
Special action (defined per DataType) that needs to be performed before creating output value (e.g. ‘ensure’ will make sure an output directory exists) automatic
Indicate that output doesn’t require commandline argument, but is created automatically by a Tool [2] method
The collector plugin to use for the gathering automatic output, see the Collector plugins location
Definition where to an automatically, usage depends on the method
[2]Footnotes
[1] (1, 2, 3, 4) datatype
andenum
are conflicting entries, if both specifieddatatype
has presedence[2] (1, 2) More details on defining automatica output are given in [TODO] -
__abstractmethods__
= frozenset()¶
-
__dataschemafile__
= 'FastrInterface.schema.json'¶
-
__getstate__
()[source]¶ Get the state of the FastrInterface object.
Returns: state of interface Return type: dict
-
__hash__
= None¶
-
__init__
(id_, document)[source]¶ The BasePlugin constructor.
Returns: the created plugin Return type: BasePlugin Raises: FastrPluginNotLoaded – if the plugin did not load correctly
-
__module__
= 'fastr.resources.plugins.interfaceplugins.fastrinterface'¶
-
check_input_id
(id_)[source]¶ Check if an id for an object is valid and unused in the Tool. The method will always returns True if it does not raise an exception.
Parameters: id (str) – the id to check
Returns: True
Raises: - FastrValueError – if the id is not correctly formatted
- FastrValueError – if the id is already in use
-
check_output_id
(id_)[source]¶ Check if an id for an object is valid and unused in the Tool. The method will always returns True if it does not raise an exception.
Parameters: id (str) – the id to check
Returns: True
Raises: - FastrValueError – if the id is not correctly formatted
- FastrValueError – if the id is already in use
-
collector_plugin_type
¶ alias of
CollectorPlugin
-
collectors
= Empty CollectorPluginManager¶
-
execute
(target, payload)[source]¶ Execute the interface using a specific target and payload (containing a set of values for the arguments)
Parameters: Returns: result of the execution
Return type:
-
expanding
¶ Indicates whether or not this Interface will result in multiple samples per run. If the flow is unaffected, this will be zero, if it is nonzero it means that number of dimension will be added to the sample array.
-
get_arguments
(values)[source]¶ Get the argument list for this interface
Returns: return list of arguments
-
get_specials
(payload, output, cardinality_nr)[source]¶ Get special attributes. Returns tuples for specials, inputs and outputs that are used for formatting substitutions.
Parameters: - output – Output for which to get the specials
- cardinality_nr (int) – the cardinality number
-
input_map
= None¶ List of input parameter descriptions
-
inputs
¶ OrderedDict of Inputs connected to the Interface. The format should be {input_id: InputSpec}.
-
output_map
= None¶ List of output parameter descriptions
-
outputs
¶ OrderedDict of Output connected to the Interface. The format should be {output_id: OutputSpec}.
-
-
class
fastr.resources.plugins.interfaceplugins.fastrinterface.
HiddenFieldMap
(*args, **kwargs)[source]¶ Bases:
collections.abc.Mapping
-
__abstractmethods__
= frozenset()¶
-
__dict__
= mappingproxy({'__module__': 'fastr.resources.plugins.interfaceplugins.fastrinterface', '__init__': <function HiddenFieldMap.__init__>, '__getitem__': <function HiddenFieldMap.__getitem__>, '__len__': <function HiddenFieldMap.__len__>, '__iter__': <function HiddenFieldMap.__iter__>, '__dict__': <attribute '__dict__' of 'HiddenFieldMap' objects>, '__weakref__': <attribute '__weakref__' of 'HiddenFieldMap' objects>, '__doc__': None, '__abstractmethods__': frozenset(), '_abc_registry': <_weakrefset.WeakSet object>, '_abc_cache': <_weakrefset.WeakSet object>, '_abc_negative_cache': <_weakrefset.WeakSet object>, '_abc_negative_cache_version': 55})¶
-
__module__
= 'fastr.resources.plugins.interfaceplugins.fastrinterface'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
fastr.resources.plugins.interfaceplugins.fastrinterface.
InputParameterDescription
(parent, element, order=0)[source]¶ Bases:
fastr.resources.plugins.interfaceplugins.fastrinterface.ParameterDescription
Description of an input parameter used by a Tool.
-
__module__
= 'fastr.resources.plugins.interfaceplugins.fastrinterface'¶
-
-
class
fastr.resources.plugins.interfaceplugins.fastrinterface.
OutputParameterDescription
(parent, element, order=0)[source]¶ Bases:
fastr.resources.plugins.interfaceplugins.fastrinterface.ParameterDescription
Description of a output parameter used by a Tool.
-
ACTIONS
= {'ensure': <function OutputParameterDescription.mkdirs>, 'mkdir': <function OutputParameterDescription.mkdirs>}¶
-
__module__
= 'fastr.resources.plugins.interfaceplugins.fastrinterface'¶
-
__setstate__
(state)[source]¶ Set the state of the OutputParameterDescription by the given state.
Parameters: state (dict) – The state to populate the object with
-
-
class
fastr.resources.plugins.interfaceplugins.fastrinterface.
ParameterDescription
(parent, element, order=0)[source]¶ Bases:
fastr.abc.serializable.Serializable
Description of an input or output parameter used by a Tool. This is the super class for both input and output, containing the shared parts.
-
__eq__
(other)[source]¶ Compare two ParameterDescription instance with eachother. This function helps ignores the parent, but once tests the values for equality
Parameters: other – the other instances to compare to Returns: True if equal, False otherwise
-
__getstate__
()[source]¶ Retrieve the state of the ParameterDescription
Returns: the state of the object Rtype dict:
-
__hash__
= None¶
-
__module__
= 'fastr.resources.plugins.interfaceplugins.fastrinterface'¶
-
-
class
fastr.resources.plugins.interfaceplugins.fastrinterface.
PathDescription
(path)[source]¶ Bases:
object
-
__dict__
= mappingproxy({'__module__': 'fastr.resources.plugins.interfaceplugins.fastrinterface', '__init__': <function PathDescription.__init__>, '__repr__': <function PathDescription.__repr__>, '__str__': <function PathDescription.__str__>, '__getitem__': <function PathDescription.__getitem__>, 'directory': <property object>, 'filename': <property object>, 'basename': <property object>, 'extension': <property object>, '__dict__': <attribute '__dict__' of 'PathDescription' objects>, '__weakref__': <attribute '__weakref__' of 'PathDescription' objects>, '__doc__': None})¶
-
__getitem__
(item)[source]¶ Forward the getitem to the path string
Parameters: item (int,slice) – the part of the path the retrieve Returns: substring
-
__init__
(path)[source]¶ Create a path description that allows access to parts
Parameters: path (str) – the path to describe
-
__module__
= 'fastr.resources.plugins.interfaceplugins.fastrinterface'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
basename
¶ The basename of the filename of the path
-
directory
¶ The directory name of the path
-
extension
¶ The extension of the path
-
filename
¶ The entire filename of the path
-
flowinterface
Module¶
-
class
fastr.resources.plugins.interfaceplugins.flowinterface.
FlowInterface
(id_, document)[source]¶ Bases:
fastr.core.interface.Interface
The Interface use for AdvancedFlowNodes to create the advanced data flows that are not implemented in the fastr. This allows nodes to implement new data flows using the plugin system.
The definition of
FlowInterfaces
are very similar to the defaultFastrInterfaces
.Note
A flow interface should be using a specific FlowPlugin
-
__abstractmethods__
= frozenset()¶
-
__dataschemafile__
= 'FastrInterface.schema.json'¶
-
__getstate__
()[source]¶ Get the state of the FastrInterface object.
Returns: state of interface Return type: dict
-
__hash__
= None¶
-
__init__
(id_, document)[source]¶ The BasePlugin constructor.
Returns: the created plugin Return type: BasePlugin Raises: FastrPluginNotLoaded – if the plugin did not load correctly
-
__module__
= 'fastr.resources.plugins.interfaceplugins.flowinterface'¶
-
execute
(target, payload)[source]¶ Execute the interface given the a target and payload. The payload should have the form {‘input’: {‘input_id_a’: (value, value), ‘input_id_b’: (value, value)},
‘output’: {‘output_id_a’: (value, value), ‘output_id_b’: (value, value)}}Parameters: - target – the target to call
- payload – the payload to use
Returns: the result of the execution
Return type: (tuple of) InterfaceResult
-
expanding
¶ Indicates whether or not this Interface will result in multiple samples per run. If the flow is unaffected, this will be zero, if it is nonzero it means that number of dimension will be added to the sample array.
-
flow_plugin_type
¶ alias of
FlowPlugin
-
flow_plugins
= Empty FlowPluginManager¶
-
inputs
¶ OrderedDict of Inputs connected to the Interface. The format should be {input_id: InputSpec}.
-
outputs
¶ OrderedDict of Output connected to the Interface. The format should be {output_id: OutputSpec}.
-
-
class
fastr.resources.plugins.interfaceplugins.flowinterface.
FlowPlugin
[source]¶ Bases:
fastr.abc.baseplugin.Plugin
Plugin that can manage an advanced data flow. The plugins override the execution of node. The execution receives all data of a node in one go, so not split per sample combination, but all data on all inputs in one large payload. The flow plugin can then re-order the data and create resulting samples as it sees fits. This can be used for all kinds of specialized data flows, e.g. cross validation.
To create a new FlowPlugin there is only one method that needs to be implemented:
execute
.-
__abstractmethods__
= frozenset({'execute'})¶
-
__module__
= 'fastr.resources.plugins.interfaceplugins.flowinterface'¶
-
-
class
fastr.resources.plugins.interfaceplugins.flowinterface.
FlowPluginManager
[source]¶ Bases:
fastr.plugins.managers.pluginmanager.PluginSubManager
Container holding all the CollectorPlugins
-
__abstractmethods__
= frozenset()¶
-
__module__
= 'fastr.resources.plugins.interfaceplugins.flowinterface'¶
-
nipypeinterface
Module¶
-
class
fastr.resources.plugins.interfaceplugins.nipypeinterface.
HiddenFieldMap
(*args, **kwargs)[source]¶ Bases:
collections.abc.Mapping
-
__abstractmethods__
= frozenset()¶
-
__dict__
= mappingproxy({'__module__': 'fastr.resources.plugins.interfaceplugins.nipypeinterface', '__init__': <function HiddenFieldMap.__init__>, '__getitem__': <function HiddenFieldMap.__getitem__>, '__len__': <function HiddenFieldMap.__len__>, '__iter__': <function HiddenFieldMap.__iter__>, '__dict__': <attribute '__dict__' of 'HiddenFieldMap' objects>, '__weakref__': <attribute '__weakref__' of 'HiddenFieldMap' objects>, '__doc__': None, '__abstractmethods__': frozenset(), '_abc_registry': <_weakrefset.WeakSet object>, '_abc_cache': <_weakrefset.WeakSet object>, '_abc_negative_cache': <_weakrefset.WeakSet object>, '_abc_negative_cache_version': 55})¶
-
__module__
= 'fastr.resources.plugins.interfaceplugins.nipypeinterface'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
fastr.resources.plugins.interfaceplugins.nipypeinterface.
NipypeInterface
(id_, nipype_cls=None, document=None)[source]¶ Bases:
fastr.core.interface.Interface
Experimental interfaces to using
nipype
interfaces directly in fastr tools, only using a simple reference.To create a tool using a nipype interface just create an interface with the correct type and set the
nipype
argument to the correct class. For example in an xml tool this would become:<interface class="NipypeInterface"> <nipype_class>nipype.interfaces.elastix.Registration</nipype_class> </interface>
Note
To use these interfaces
nipype
should be installed on the system.Warning
This interface plugin is basically functional, but highly experimental!
-
__abstractmethods__
= frozenset()¶
-
__getstate__
()[source]¶ Retrieve the state of the Interface
Returns: the state of the object Rtype dict:
-
__hash__
= None¶
-
__init__
(id_, nipype_cls=None, document=None)[source]¶ The BasePlugin constructor.
Returns: the created plugin Return type: BasePlugin Raises: FastrPluginNotLoaded – if the plugin did not load correctly
-
__module__
= 'fastr.resources.plugins.interfaceplugins.nipypeinterface'¶
-
execute
(target, payload)[source]¶ Execute the interface using a specific target and payload (containing a set of values for the arguments)
Parameters: Returns: result of the execution
Return type:
-
expanding
¶ Indicates whether or not this Interface will result in multiple samples per run. If the flow is unaffected, this will be zero, if it is nonzero it means that number of dimension will be added to the sample array.
-
inputs
¶ OrderedDict of Inputs connected to the Interface. The format should be {input_id: InputSpec}.
-
outputs
¶ OrderedDict of Output connected to the Interface. The format should be {output_id: OutputSpec}.
-