plumpy.process_spec module¶
-
class
plumpy.process_spec.
ProcessSpec
[source]¶ Bases:
object
A class that defines the specifications of a
plumpy.Process
, this includes what its inputs, outputs, etc are.All methods to modify the spec should have declarative names describe the spec e.g.: input, output
Every Process class has one of these.
-
INPUT_PORT_TYPE
¶ alias of
plumpy.ports.InputPort
-
OUTPUT_PORT_TYPE
¶ alias of
plumpy.ports.OutputPort
-
PORT_NAMESPACE_TYPE
¶ alias of
plumpy.ports.PortNamespace
-
_create_port
(port_namespace: plumpy.ports.PortNamespace, port_class: Type[Union[plumpy.ports.Port, plumpy.ports.PortNamespace]], name: str, **kwargs: Any) → None[source]¶ Create a new Port of a given class and name in a given PortNamespace
- Parameters
port_namespace – PortNamespace to which to add the port
port_class – class of the Port to create
name – name of the port to create
kwargs – options for the port
-
static
_expose_ports
(process_class: Type[Process], source: plumpy.ports.PortNamespace, destination: plumpy.ports.PortNamespace, expose_memory: Dict[Optional[str], Dict[Type[Process], Sequence[str]]], namespace: Optional[str], exclude: Optional[Sequence[str]], include: Optional[Sequence[str]], namespace_options: Optional[dict] = None) → None[source]¶ Expose ports from a source PortNamespace of the ProcessSpec of a Process class into the destination PortNamespace of this ProcessSpec. If the namespace is specified, the ports will be exposed in that sub namespace. The set of ports can be restricted using the mutually exclusive exclude and include tuples. The namespace_options will be used to override the properties of the PortNamespace into which the ports are exposed, whether that has been newly created or existed already.
- Parameters
process_class – the Process class whose outputs to expose
source – the PortNamespace whose ports are to be exposed
destination – the PortNamespace into which the ports are to be exposed
namespace – a namespace in which to place PortNamespace with the exposed outputs
exclude – input ports that are to be excluded
include – input ports that are to be included
namespace_options – a dictionary with mutable PortNamespace property values to override
-
expose_inputs
(process_class: Type[Process], namespace: Optional[str] = None, exclude: Optional[Sequence[str]] = None, include: Optional[Sequence[str]] = None, namespace_options: Optional[dict] = None) → None[source]¶ This method allows one to automatically add the inputs from another Process to this ProcessSpec. The optional namespace argument can be used to group the exposed inputs in a separated PortNamespace. The exclude and include arguments can be used to restrict the set of ports that are exposed. Note that these two options are mutually exclusive.
- Parameters
process_class – the Process class whose inputs to expose
namespace – a namespace in which to place the exposed inputs
exclude – input ports that are to be excluded
include – input ports that are to be included
namespace_options – a dictionary with mutable PortNamespace property values to override
-
expose_outputs
(process_class: Type[Process], namespace: Optional[str] = None, exclude: Optional[Sequence[str]] = None, include: Optional[Sequence[str]] = None, namespace_options: Optional[dict] = None) → None[source]¶ This method allows one to automatically add the ouputs from another Process to this ProcessSpec. The optional namespace argument can be used to group the exposed outputs in a separated PortNamespace. The exclude and include arguments can be used to restrict the set of ports that are exposed. Note that these two options are mutually exclusive.
- Parameters
process_class – the Process class whose outputs to expose
namespace – a namespace in which to place the exposed outputs
exclude – input ports that are to be excluded
include – input ports that are to be included
namespace_options – a dictionary with mutable PortNamespace property values to override
-
get_description
() → Dict[str, Any][source]¶ Get a description of this process specification
- Returns
a dictionary with the descriptions of the input and output port namespaces
-
has_input
(name: str) → bool[source]¶ Return whether the input port namespace contains a port with the given name
- Parameters
name – key of the port in the input port namespace
-
has_output
(name: str) → bool[source]¶ Return whether the output port namespace contains a port with the given name
- Parameters
name – key of the port in the output port namespace
-
input
(name: str, **kwargs: Any) → None[source]¶ Define an input port in the input port namespace
- Parameters
name – name of the input port to create
kwargs – options for the input port
-
input_namespace
(name: str, **kwargs: Any) → None[source]¶ Create a new PortNamespace in the input port namespace. The keyword arguments will be passed to the PortNamespace constructor. Any intermediate port namespaces that need to be created for a nested namespace, will take constructor defaults
- Parameters
name – namespace of the new port namespace
kwargs – keyword arguments for the PortNamespace constructor
-
property
inputs
¶ Get the input port namespace of the process specification
- Returns
the input PortNamespace
-
property
logger
¶
-
property
namespace_separator
¶
-
output
(name: str, **kwargs: Any) → None[source]¶ Define an output port in the output port namespace
- Parameters
name – name of the output port to create
kwargs – options for the output port
-
output_namespace
(name: str, **kwargs: Any) → None[source]¶ Create a new PortNamespace in the output port namespace. The keyword arguments will be passed to the PortNamespace constructor. Any intermediate port namespaces that need to be created for a nested namespace, will take constructor defaults
- Parameters
name – namespace of the new port namespace
kwargs – keyword arguments for the PortNamespace constructor
-
property
outputs
¶ Get the output port namespace of the process specification
- Returns
the outputs PortNamespace
-
property
ports
¶
-