pypz.core.specs.misc module
- class pypz.core.specs.misc.BlankInputPortPlugin(name: str = None, *args, **kwargs)
Bases:
InputPortPlugin
,BlankPortPlugin
- _abc_impl = <_abc._abc_data object>
- can_retrieve() bool
This method shall implement the logic to signalize, whether the InputPort is still able to retrieve. Unable can mean for example that the OutputPort finished writing. This can be then used to terminate reading.
- Returns:
True if port can retrieve, False if not
- commit_current_read_offset() None
This method shall implement the logic of committing the current read offset based on the technology used.
- retrieve() Any
This method shall implement the logic to retrieve data through the port.
- Returns:
tbd by the implementation
- class pypz.core.specs.misc.BlankInstance(name: str = None, *args, **kwargs)
Bases:
Instance
[BlankNestedInstanceType
]- __context: Instance
Reference to the context aka parent object. Derived automatically in the override implementation of __setattr__.
- __depends_on: set
Set of other instances that is this instance depending on. Note however that the type of the dependencies are checked dynamically in runtime, since dependencies can only be defined on the same type of instance.
- __expected_parameters: dict[str, ExpectedParameter]
Map of expected parameters defined as descriptor of the class. Key is the name of the parameter, value is the parameter descriptor. Used to check, if an expected (described) parameter value shall be set upon instance parameter setting.
- __full_name: str
Full name of the instance which uniquely identifies it up to its topmost context. For example, if an instance A has a parent context B, which has a parent context C, then the full name of A is ‘C.B.A’. This value is calculated and the result is stored after the first calculation to avoid recalculation every time.
- __nested_instance_type: Type[NestedInstanceType] | None
Stores the specified type of the nested instances. This is required to be able to discover those instances
- __nested_instances: dict[str, NestedInstanceType]
This dictionary holds all the instances that are nested in the context of this instance object
- __parameters: InstanceParameters
The interpreted instance parameters i.e., cascading and templates are interpreted
- __simple_name: str
Name of the instance, which is represented by the object created from the implementation class. If not provided and there is a parent context, then the parent context will use the name of the variable.
- __spec_classes: set
Set of specs classes that are in the class hierarchy i.e., which specs classes are contributing to the implementation of this class
- __spec_name: str
The name of the spec constructed of module and qualified class name. Notice that we separate the module name and the class name so that we can identify them at loading by name.
- _abc_impl = <_abc._abc_data object>
- _on_error(source: Any, exception: Exception) None
This method can be implemented to react to error events during execution. The error itself may come from arbitrary sources.
- _on_interrupt(system_signal: int = None) None
This method can be implemented to react to interrupt signals like SIGINT, SIGTERM etc. The specs implementation can then execute interrupt logic e.g., early termination of loops.
- Parameters:
system_signal – id of the system signal that causes interrupt
- class pypz.core.specs.misc.BlankOperator(name: str = None, *args, **kwargs)
Bases:
Operator
,BlankInstance
[Plugin
]- __context: Instance
Reference to the context aka parent object. Derived automatically in the override implementation of __setattr__.
- __depends_on: set
Set of other instances that is this instance depending on. Note however that the type of the dependencies are checked dynamically in runtime, since dependencies can only be defined on the same type of instance.
- __expected_parameters: dict[str, ExpectedParameter]
Map of expected parameters defined as descriptor of the class. Key is the name of the parameter, value is the parameter descriptor. Used to check, if an expected (described) parameter value shall be set upon instance parameter setting.
- __full_name: str
Full name of the instance which uniquely identifies it up to its topmost context. For example, if an instance A has a parent context B, which has a parent context C, then the full name of A is ‘C.B.A’. This value is calculated and the result is stored after the first calculation to avoid recalculation every time.
- __nested_instance_type: Type[NestedInstanceType] | None
Stores the specified type of the nested instances. This is required to be able to discover those instances
- __nested_instances: dict[str, NestedInstanceType]
This dictionary holds all the instances that are nested in the context of this instance object
- __parameters: InstanceParameters
The interpreted instance parameters i.e., cascading and templates are interpreted
- __simple_name: str
Name of the instance, which is represented by the object created from the implementation class. If not provided and there is a parent context, then the parent context will use the name of the variable.
- __spec_classes: set
Set of specs classes that are in the class hierarchy i.e., which specs classes are contributing to the implementation of this class
- __spec_name: str
The name of the spec constructed of module and qualified class name. Notice that we separate the module name and the class name so that we can identify them at loading by name.
- _abc_impl = <_abc._abc_data object>
- _on_init() bool
This method shall implement the logic to initialize the operation. It will be called after services are started and resources are created.
- Returns:
True, if finished
False, if more iteration required (to not block the execution)
- _on_running() bool | None
This method shall implement the actual business logic. It will be called after the _on_init has successfully finished
- Returns:
True, if finished
False, if more iteration required (to not block the execution)
None, if automatically to be determined based on all inputs i.e., if no more input record, then finish
- _on_shutdown() bool
This method shall implement the logic to shut down the operation. It will be called, after the _on_running has successfully finished.
- Returns:
True, if finished
False, if more iteration required (to not block the execution)
- class pypz.core.specs.misc.BlankOutputPortPlugin(name: str = None, *args, **kwargs)
Bases:
OutputPortPlugin
,BlankPortPlugin
- _abc_impl = <_abc._abc_data object>
- send(data: Any) Any
This method shall implement the logic to send data provided as argument. The implementation shall specify the type of the data and the return value.
- Parameters:
data – data to be sent
- Returns:
tbd by the implementation
- class pypz.core.specs.misc.BlankPlugin(name: str = None, *args, **kwargs)
Bases:
BlankInstance
[None
]- __context: Instance
Reference to the context aka parent object. Derived automatically in the override implementation of __setattr__.
- __depends_on: set
Set of other instances that is this instance depending on. Note however that the type of the dependencies are checked dynamically in runtime, since dependencies can only be defined on the same type of instance.
- __expected_parameters: dict[str, ExpectedParameter]
Map of expected parameters defined as descriptor of the class. Key is the name of the parameter, value is the parameter descriptor. Used to check, if an expected (described) parameter value shall be set upon instance parameter setting.
- __full_name: str
Full name of the instance which uniquely identifies it up to its topmost context. For example, if an instance A has a parent context B, which has a parent context C, then the full name of A is ‘C.B.A’. This value is calculated and the result is stored after the first calculation to avoid recalculation every time.
- __nested_instance_type: Type[NestedInstanceType] | None
Stores the specified type of the nested instances. This is required to be able to discover those instances
- __nested_instances: dict[str, NestedInstanceType]
This dictionary holds all the instances that are nested in the context of this instance object
- __parameters: InstanceParameters
The interpreted instance parameters i.e., cascading and templates are interpreted
- __simple_name: str
Name of the instance, which is represented by the object created from the implementation class. If not provided and there is a parent context, then the parent context will use the name of the variable.
- __spec_classes: set
Set of specs classes that are in the class hierarchy i.e., which specs classes are contributing to the implementation of this class
- __spec_name: str
The name of the spec constructed of module and qualified class name. Notice that we separate the module name and the class name so that we can identify them at loading by name.
- _abc_impl = <_abc._abc_data object>
- class pypz.core.specs.misc.BlankPortPlugin(name: str = None, *args, **kwargs)
Bases:
PortPlugin
,BlankPlugin
- _abc_impl = <_abc._abc_data object>
- _on_port_close() bool
This method shall implement the logic to shut down the i/o port functionalities.
- Returns:
True succeeded, False if more iteration required (to not block the execution)
- _on_port_open() bool
This method shall implement the logic to initialize the i/o port functionalities.
- Returns:
True succeeded, False if more iteration required (to not block the execution)
- class pypz.core.specs.misc.BlankResourceHandlerPlugin(name: str = None, *args, **kwargs)
Bases:
ResourceHandlerPlugin
,BlankPlugin
- _abc_impl = <_abc._abc_data object>
- _on_resource_creation() bool
This method shall implement the logic to create an arbitrary resource of any type.
- Returns:
True succeeded, False if more iteration required (to not block the execution)
- _on_resource_deletion() bool
This method shall implement the logic to destroy the created resource.
- Returns:
True succeeded, False if more iteration required (to not block the execution)
- class pypz.core.specs.misc.BlankServicePlugin(name: str = None, *args, **kwargs)
Bases:
ServicePlugin
,BlankPlugin
- _abc_impl = <_abc._abc_data object>
- _on_service_shutdown() bool
This method shall implement the logic of stopping the service and clean up the residuals. E.g., a mounting service could unmount or a background thread could be stopped. VERY IMPORTANT NOTE - you must always check, if your service start method has been called, because it can be that it is never called, if there was an exception raised from other entity. However, the shutdown will be called anyway.
- Returns:
True if logic finished, False if it needs more iteration
- _on_service_start() bool
This method shall implement the starting logic of the service. You can consider services as example like mounting service, which only mounts a folder to the system or a background service, which starts a background thread.
- Returns:
True if logic finished, False if it needs more iteration