Module Registry

class vistrails.core.modules.module_registry.ModuleRegistry(*args, **kwargs)

Global registry of modules.

This holds all the ModuleDescriptor objects for the VisTrails modules of enabled packages.

add_input_port(module, portName, portSignature, optional=False, sort_key=-1, labels=None, defaults=None, values=None, entry_types=None, docstring=None, shape=None, min_conns=0, max_conns=-1, depth=0)

Registers a module’s input port.

add_module(module, **kwargs)

Add a module to the registry.

Options are taken from the _settings attribute, a ModuleSettings instance. All of the attributes of that class may also be used as kwargs to add_module().

Returns:The new ModuleDescriptor
add_module_from_settings(module, settings)

Adds a module to the registry, with an explicit ModuleSettings.

See ModuleSettings.

Returns:The new ModuleDescriptor
add_output_port(module, portName, portSignature, optional=False, sort_key=-1, docstring=None, shape=None, min_conns=0, max_conns=-1, depth=0)

Registers a module’s output port.

all_destination_ports(descriptor, sorted=True)

Returns input ports, including inherited, for the given module

all_source_ports(descriptor, sorted=True)

Returns output ports, including inherited, for the given module.

are_specs_matched(sub, super, allow_conversion=False, out_converters=None)

Checks if specs of sub subclass super.

auto_add_module(module)

Add a module to the regsitry.

Don’t call this directly - it is meant to be used by the PackageManager, when inspecting a package’s contents.

auto_add_ports(module)

Add input/output ports to the registry.

This isn’t meant to be called directly – it is used by the PackageManager to register modules automatically by inspecting a package’s contents.

delete_input_port(descriptor, port_name)

Remove an input port by name.

delete_module(identifier, module_name, namespace=None)

Removes a module from the registry.

delete_output_port(descriptor, port_name)

Removes an output port by name.

find_descriptor_superclass(d1, d2)

Finds the lowest common superclass descriptor for d1 and d2

Returns:The ModuleDescriptor or None
get_descriptor(module)

Gets a ModuleDescriptor from a given Module subclass.

get_descriptor_by_name(identifier, name, namespace='', package_version='', module_version='')

Gets the specified descriptor from the registry.

If you do not specify package_version, you will get the currently loaded version. If you do not specify the module_version, you will get the most recent version. Note that module_version is currently only used for abstractions.

Raises ModuleRegistryException:
 if lookup fails.
get_descriptor_from_module(module)

Gets a ModuleDescriptor from a given Module subclass.

get_descriptor_from_name_only(name)

Gets a ModuleDescriptor from a name.

This tries to return a descriptor from a name without a package. The call should only be used for converting from legacy vistrails to new ones. For one, it is slow on misses.

Deprecated since version 1.0: This is very unsafe and get_descriptor_by_name should be used instead.

get_descriptor_subclasses(descriptor)

Finds descriptors that subclass the given descriptor.

get_input_port_spec(module, portName)

Gets a PortSpec from a pipeline module and an input port name.

Return type:ModuleDescriptor | None
get_module_by_name(identifier, name, namespace=None)

Gets a module (the class) from its name and package.

Returns:The subclass of Module registered under the given name (not the ModuleDescriptor).
get_module_hierarchy(descriptor)

Returns the module and all its parents, in order.

This will return all the modules descriptor from the given one to the one for the root Module. It will thus not return mixins (which themselves don’t subclass Module).

get_output_port_spec(module, portName)

Gets a PortSpec from a pipeline module and an output port name.

Return type:ModuleDescriptor | None
get_port_from_all_destinations(descriptor, name)

Gets an input port, possibly inherited, on the given module.

static get_subclass_candidates(module)

Returns all Module superclasses of the given Module class.

Returns the superclasses of the given Module subclass, but only those that are subclasses of Module themselves. This means that mixins won’t be returned, since they don’t subclass Module directly.

Return type:list[class]
is_descriptor_subclass(sub, super)

Checks whether a descriptor subclasses another.

is_port_sub_type(sub, super)

Checks whether sub is a subclass of super.

They must also have the same type (both input or both output) and name.

method_ports(module_descriptor)

Returns port specs that only contain subclasses of Constant.

Return type:list[PortSpec]
module_signature(pipeline, module)

Computes the signature of a Module in a given Pipeline.

This might involve a user-defined hasher.

port_and_port_spec_match(port, port_spec)

Checks whether the ports match, i.e. have the same signature.

They must also have the same type (both input or both output) and name.

Return type:bool
ports_can_connect(sourceModulePort, destinationModulePort, allow_conversion=False, out_converters=None)

Checks whether the given ports can be connected.

remove_package(package)

Removes an entire package from the registry.

set_current_package(package)

Set the current package for all add_module() operations.

This means that all modules added after this call will be assigned to the specified package. Set package to None to indicate that VisTrails default package should be used instead.

Do not call this directly. The package manager will call this with the correct value prior to calling ‘initialize’ on the package.

class vistrails.core.modules.module_descriptor.ModuleDescriptor(*args, **kwargs)

Description of a VisTrails module in the registry.

There exists exactly one ModuleDescriptor for every registered VisTrails module in the system. It holds information about a module, such as its name, package identifier and ports.

Attribute module:
 reference to the python class that defines the module
Attribute name:name of the module
Attribute identifier:
 identifier of the package that module belongs to
Attribute input_ports:
 dictionary of names of input ports to the types consumed by the ports
Attribute output_ports:
 dictionary of names of output ports to the types produces by the ports
Attribute input_ports_optional:
 dictionary of input port names that records whether ports should show up by default on GUI
Attribute output_ports_optional:
 dictionary of output port names that records whether ports should show up by default on GUI
Attribute port_order:
 stores a map from names to numbers to order the ports in the GUI
Attribute _is_abstract:
 whether module is abstract
Attribute _configuration_widget:
 reference to the Qt class that provides a custom configuration widget for the class. Note that this can be a tuple (path, name) that will be loaded only when needed via __import__ (! this is preferred !) or as a QWidget (deprecated)
Attribute _left_fringe, _right_fringe:
 lists of 2D points that define a drawing style for modules in the GUI
Attribute _module_color:
 color of the module in the GUI
Attribute _widget_item:
 stores a reference to the ModuleTreeWidgetItem so that when ports are added to modules things get correctly updated.
Attribute _input_port_cache, _output_port_cache, _port_caches:
 Dictionaries for fast port spec lookup, created because port spec lookups are sometimes part of hot code paths and need to go as fast as possible.
has_ports()

Returns True is module has any ports (this includes superclasses). This method exists to make automatic abstract module detection efficient.

new_input_port()

Updates needed variables when new input port is added to either this module or the superclass.

new_output_port()

Updates needed variables when new output port is added to either this module or the superclass.

port_count()

Return the total number of available for the module.

set_configuration_widget(configuration_widget_type)

set_configuration_widget(configuration_widget_type: (path, name) tuple or QWidget) -> None