anom_processing
Top-level package for kiara_plugin.anom_processing.
KIARA_METADATA
¶
find_data_types: Union[Type, Tuple, Callable]
¶
find_model_classes: Union[Type, Tuple, Callable]
¶
find_modules: Union[Type, Tuple, Callable]
¶
find_pipelines: Union[Type, Tuple, Callable]
¶
get_version()
¶
Source code in anom_processing/__init__.py
def get_version():
from pkg_resources import DistributionNotFound, get_distribution
try:
# Change here if project is renamed and does not equal the package name
dist_name = __name__
__version__ = get_distribution(dist_name).version
except DistributionNotFound:
try:
version_file = os.path.join(os.path.dirname(__file__), "version.txt")
if os.path.exists(version_file):
with open(version_file, encoding="utf-8") as vf:
__version__ = vf.read()
else:
__version__ = "unknown"
except (Exception):
pass
if __version__ is None:
__version__ = "unknown"
return __version__
Modules¶
data_types
¶
This module contains the value type classes that are used in the kiara_plugin.anom_processing package.
models
¶
This module contains the metadata (and other) models that are used in the kiara_plugin.anom_processing package.
Those models are convenience wrappers that make it easier for kiara to find, create, manage and version metadata -- but also other type of models -- that is attached to data, as well as kiara modules.
Metadata models must be a sub-class of [kiara.metadata.MetadataModel][]. Other models usually sub-class a pydantic BaseModel or implement custom base classes.
modules
special
¶
Classes¶
ExampleModule (KiaraModule)
¶
A very simple example module; concatenate two strings.
The purpose of this modules is to show the main elements of a KiaraModule:
- the (optional) configuration class: must inherit from
KiaraModuleConfig, and the config class must be set as the_config_clsattribute on theKiaraModuleclass. Configuration values can be retrieved via theself.get_config_value(key)method - the inputs description: must return a dictionary, containing the input name(s) as keys, and another dictionary containing type_name information and documentation about the input data as value
- the outputs description: must return a dictionary, containing the output name(s) as keys, and another dictionary containing type_name information and documentation about the output data as value
- the
processmethod: this is where the actual work gets done. Input data can be accessed viainputs.get_value_data(key), results can be set with theoutputs.set_value(key, value)method
Examples:
This example module can be tested on the commandline with the kiara run command:
kiara run core_types.example text_1="xxx" text_2="yyy"
Source code in anom_processing/modules/__init__.py
class ExampleModule(KiaraModule):
"""A very simple example module; concatenate two strings.
The purpose of this modules is to show the main elements of a [`KiaraModule`][kiara.modules.KiaraModule]:
- ***the (optional) configuration class***: must inherit from [`KiaraModuleConfig`][kiara.modules.KiaraModuleConfig], and the config class must be set as the `_config_cls` attribute
on the `KiaraModule` class. Configuration values can be retrieved via the [`self.get_config_value(key)`][kiara.modules.KiaraModule.get_config_value] method
- ***the inputs description***: must return a dictionary, containing the input name(s) as keys, and another dictionary containing type_name information
and documentation about the input data as value
- ***the outputs description***: must return a dictionary, containing the output name(s) as keys, and another dictionary containing type_name information
and documentation about the output data as value
- ***the ``process`` method***: this is where the actual work gets done. Input data can be accessed via ``inputs.get_value_data(key)``, results
can be set with the ``outputs.set_value(key, value)`` method
Example:
This example module can be tested on the commandline with the ``kiara run`` command:
```
kiara run core_types.example text_1="xxx" text_2="yyy"
```
"""
_config_cls = ExampleModuleConfig
_module_type_name = "anom_processing.example"
def create_inputs_schema(
self,
) -> ValueMapSchema:
inputs = {
"text_1": {"type": "string", "doc": "The first text."},
"text_2": {"type": "string", "doc": "The second text."},
}
return inputs
def create_outputs_schema(
self,
) -> ValueMapSchema:
outputs = {
"text": {
"type": "string",
"doc": "The concatenated text.",
}
}
return outputs
def process(self, inputs: ValueMap, outputs: ValueMap) -> None:
separator = self.get_config_value("separator")
text_1 = inputs.get_value_data("text_1")
text_2 = inputs.get_value_data("text_2")
result = text_1 + separator + text_2
outputs.set_value("text", result)
Classes¶
_config_cls (KiaraModuleConfig)
private
pydantic-model
¶Methods¶
create_inputs_schema(self)
¶Return the schema for this types' inputs.
Source code in anom_processing/modules/__init__.py
def create_inputs_schema(
self,
) -> ValueMapSchema:
inputs = {
"text_1": {"type": "string", "doc": "The first text."},
"text_2": {"type": "string", "doc": "The second text."},
}
return inputs
create_outputs_schema(self)
¶Return the schema for this types' outputs.
Source code in anom_processing/modules/__init__.py
def create_outputs_schema(
self,
) -> ValueMapSchema:
outputs = {
"text": {
"type": "string",
"doc": "The concatenated text.",
}
}
return outputs
process(self, inputs, outputs)
¶Source code in anom_processing/modules/__init__.py
def process(self, inputs: ValueMap, outputs: ValueMap) -> None:
separator = self.get_config_value("separator")
text_1 = inputs.get_value_data("text_1")
text_2 = inputs.get_value_data("text_2")
result = text_1 + separator + text_2
outputs.set_value("text", result)
ExampleModuleConfig (KiaraModuleConfig)
pydantic-model
¶
pipelines
special
¶
Default (empty) module that is used as a base path for pipelines contained in this package.