modules
Attributes¶
yaml = StringYAML()
module-attribute
¶
KIARA_CONFIG = TypeVar('KIARA_CONFIG', bound=KiaraModuleConfig)
module-attribute
¶
ValueMapSchema = Mapping[str, Union[ValueSchema, Mapping[str, Any]]]
module-attribute
¶
ValueSetSchema = Mapping[str, Union[ValueSchema, Mapping[str, Any]]]
module-attribute
¶
log = structlog.getLogger()
module-attribute
¶
DEFAULT_IDEMPOTENT_MODULE_CHARACTERISTICS = ModuleCharacteristics()
module-attribute
¶
DEFAULT_NO_IDEMPOTENT_MODULE_CHARACTERISTICS = ModuleCharacteristics(is_idempotent=False)
module-attribute
¶
DEFAULT_IDEMPOTENT_INTERNAL_MODULE_CHARACTERISTICS = ModuleCharacteristics(is_internal=True)
module-attribute
¶
Classes¶
InputOutputObject
¶
Bases: abc.ABC
Abstract base class for classes that define inputs and outputs schemas.
Both the 'create_inputs_schemaand
creawte_outputs_schema` methods implemented by child classes return a description of the input schema of this module.
If returning a dictionary of dictionaries, the format of the return value is as follows (items with '*' are optional):
{
"[input_field_name]: {
"type": "[type]",
"doc*": "[a description of this input]",
"optional*': [boolean whether this input is optional or required (defaults to 'False')]
"[other_input_field_name]: {
"type: ...
...
}
Source code in kiara/modules/__init__.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
Attributes¶
alias: str
property
¶
inputs_schema: Mapping[str, ValueSchema]
property
¶
The input schema for this module.
full_inputs_schema: Mapping[str, ValueSchema]
property
¶
constants: Mapping[str, ValueSchema]
property
¶
outputs_schema: Mapping[str, ValueSchema]
property
¶
The output schema for this module.
input_names: Iterable[str]
property
¶
A list of input field names for this module.
output_names: Iterable[str]
property
¶
A list of output field names for this module.
Functions¶
input_required(input_name: str)
¶
Source code in kiara/modules/__init__.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
create_inputs_schema() -> ValueMapSchema
abstractmethod
¶
Return the schema for this types' inputs.
Source code in kiara/modules/__init__.py
127 128 129 130 131 |
|
create_outputs_schema() -> ValueMapSchema
abstractmethod
¶
Return the schema for this types' outputs.
Source code in kiara/modules/__init__.py
133 134 135 136 137 |
|
augment_module_inputs(inputs: Mapping[str, Any]) -> Dict[str, Any]
¶
Source code in kiara/modules/__init__.py
258 259 260 261 262 263 264 |
|
ModuleCharacteristics
¶
Bases: BaseModel
Source code in kiara/modules/__init__.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
Attributes¶
is_idempotent: bool = Field(description='Whether this module is idempotent (aka always produces the same output with the same inputs.', default=True)
class-attribute
¶
is_internal: bool = Field(description="Hint for frontends whether this module is used predominantly internally, and users won't need to know of its existence.", default=False)
class-attribute
¶
unique_result_values: bool = Field(description="Don't re-use existing values for outputs that have matching hashes in the data store.", default=True)
class-attribute
¶
Classes¶
KiaraModule
¶
Bases: InputOutputObject
, Generic[KIARA_CONFIG]
The base class that every custom module in Kiara needs to inherit from.
The core of every KiaraModule
is a process
method, which should be a 'pure',
idempotent function that creates one or several output values from the given input(s), and its purpose is to transfor
a set of inputs into a set of outputs.
Every module can be configured. The module configuration schema can differ, but every one such configuration needs to
subclass the [KiaraModuleConfig][kiara.module_config.KiaraModuleConfig] class and set as the value to the
_config_cls
attribute of the module class. This is useful, because it allows for some modules to serve a much
larger variety of use-cases than non-configurable modules would be, which would mean more code duplication because
of very simlilar, but slightly different module data_types.
Each module class (type) has a unique -- within a kiara context -- module type id which can be accessed via the
_module_type_name
class attribute.
Examples:
A simple example would be an 'addition' module, with a
and b
configured as inputs, and z
as the output field name.
An implementing class would look something like this:
TODO
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module_config |
Union[None, KIARA_CONFIG, Mapping[str, Any]]
|
the configuation for this module |
None
|
Source code in kiara/modules/__init__.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
|
Attributes¶
_config_cls: Type[KIARA_CONFIG] = KiaraModuleConfig
class-attribute
¶
manifest: Manifest
property
¶
doc: DocumentationMetadataModel
property
¶
module_id: uuid.UUID
property
¶
The id of this module.
module_type_name: str
property
¶
config: KIARA_CONFIG
property
¶
Retrieve the configuration object for this module.
Returns:
Type | Description |
---|---|
KIARA_CONFIG
|
the module-class-specific config object |
module_instance_cid: CID
property
¶
characteristics: ModuleCharacteristics
property
¶
operation: Operation
property
¶
Functions¶
is_pipeline() -> bool
classmethod
¶
Check whether this module type is a pipeline, or not.
Source code in kiara/modules/__init__.py
328 329 330 331 |
|
get_config_value(key: str) -> Any
¶
Retrieve the value for a specific configuration option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
the config key |
required |
Returns:
Type | Description |
---|---|
Any
|
the value for the provided key |
Source code in kiara/modules/__init__.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
|
run(kiara: Kiara, **inputs: Any) -> ValueMap
¶
Run the module ad-hoc.
This is mostly used in unit tests, you typically want to run a module via the KiaraAPI instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kiara |
Kiara
|
the kiara context |
required |
inputs |
Any
|
the inputs for this module |
{}
|
Returns:
Type | Description |
---|---|
ValueMap
|
the outputs of this module run as a ValueMap instance |
Source code in kiara/modules/__init__.py
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
|
process_step(inputs: ValueMap, outputs: ValueMap, job_log: JobLog) -> None
¶
Kick off processing for a specific set of input/outputs.
This method calls the implemented [process][kiara.module.KiaraModule.process] method of the inheriting class, as well as wrapping input/output-data related functionality.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
ValueMap
|
the input value set |
required |
outputs |
ValueMap
|
the output value set |
required |
Source code in kiara/modules/__init__.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
|
create_renderable(**config) -> RenderableType
¶
Source code in kiara/modules/__init__.py
567 568 569 |
|