class_loading
Attributes¶
logger = structlog.getLogger()
module-attribute
¶
KiaraEntryPointItem = Union[Type, Tuple, Callable]
module-attribute
¶
KiaraEntryPointIterable = Iterable[KiaraEntryPointItem]
module-attribute
¶
SUBCLASS_TYPE = TypeVar('SUBCLASS_TYPE')
module-attribute
¶
Classes¶
Functions¶
find_subclasses_under(base_class: Type[SUBCLASS_TYPE], python_module: Union[str, ModuleType]) -> List[Type[SUBCLASS_TYPE]]
¶
Find all (non-abstract) subclasses of a base class that live under a module (recursively).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_class |
Type[SUBCLASS_TYPE]
|
the parent class |
required |
python_module |
Union[str, ModuleType]
|
the Python module to search |
required |
Returns:
Type | Description |
---|---|
List[Type[SUBCLASS_TYPE]]
|
a list of all subclasses |
Source code in kiara/utils/class_loading.py
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 |
|
load_all_subclasses_for_entry_point(entry_point_name: str, base_class: Type[SUBCLASS_TYPE], ignore_abstract_classes: bool = True, type_id_key: Union[str, None] = None, type_id_func: Union[Callable, None] = None, type_id_no_attach: bool = False, attach_python_metadata: Union[bool, str] = False) -> Dict[str, Type[SUBCLASS_TYPE]]
¶
Find all subclasses of a base class via package entry points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry_point_name |
str
|
the entry point name to query entries for |
required |
base_class |
Type[SUBCLASS_TYPE]
|
the base class to look for |
required |
ignore_abstract_classes |
bool
|
whether to include abstract classes in the result |
True
|
type_id_key |
Union[str, None]
|
if provided, the found classes will have their id attached as an attribute, using the value of this as the name. if an attribute of this name already exists, it will be used as id without further processing |
None
|
type_id_func |
Union[Callable, None]
|
a function to take the found class as input, and returns a string representing the id of the class. By default, the module path + "." + class name (snake-case) is used (minus the string 'kiara_modules. |
None
|
type_id_no_attach |
bool
|
in case you want to use the type_id_key to set the id, but don't want it attached to classes that don't have it, set this to true. In most cases, you won't need this option |
False
|
attach_python_metadata |
Union[bool, str]
|
whether to attach a PythonClass metadata model to the class. By default, '_python_class' is used as attribute name if this argument is 'True', If this argument is a string, that will be used as name instead. |
False
|
Source code in kiara/utils/class_loading.py
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 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 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 |
|
find_all_kiara_modules() -> Dict[str, Type[KiaraModule]]
¶
Find all [KiaraModule][kiara.module.KiaraModule] subclasses via package entry points.
TODO
Source code in kiara/utils/class_loading.py
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 |
|
find_all_kiara_model_classes() -> Dict[str, Type[KiaraModel]]
¶
Find all [KiaraModule][kiara.module.KiaraModule] subclasses via package entry points.
TODO
Source code in kiara/utils/class_loading.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
|
find_all_archive_types() -> Dict[str, Type[KiaraArchive]]
¶
Find all KiaraArchive subclasses via package entry points.
Source code in kiara/utils/class_loading.py
431 432 433 434 435 436 437 438 439 440 441 442 |
|
find_all_data_types() -> Dict[str, Type[DataType]]
¶
Find all [KiaraModule][kiara.module.KiaraModule] subclasses via package entry points.
TODO
Source code in kiara/utils/class_loading.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
|
find_all_operation_types() -> Dict[str, Type[OperationType]]
¶
Source code in kiara/utils/class_loading.py
469 470 471 472 473 474 475 476 477 478 |
|
find_kiara_modules_under(module: Union[str, ModuleType]) -> List[Type[KiaraModule]]
¶
Source code in kiara/utils/class_loading.py
481 482 483 484 485 486 487 488 489 490 |
|
find_kiara_model_classes_under(module: Union[str, ModuleType]) -> List[Type[KiaraModel]]
¶
Source code in kiara/utils/class_loading.py
493 494 495 496 497 498 499 500 501 502 503 504 |
|
find_data_types_under(module: Union[str, ModuleType]) -> List[Type[DataType]]
¶
Source code in kiara/utils/class_loading.py
521 522 523 524 525 526 527 528 |
|
find_operations_under(module: Union[str, ModuleType]) -> List[Type[OperationType]]
¶
Source code in kiara/utils/class_loading.py
531 532 533 534 535 536 537 538 539 540 |
|
find_pipeline_base_path_for_module(module: Union[str, ModuleType]) -> Union[str, None]
¶
Source code in kiara/utils/class_loading.py
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
|
find_all_kiara_pipeline_paths(skip_errors: bool = False) -> Dict[str, Union[Dict[str, Any], None]]
¶
Source code in kiara/utils/class_loading.py
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 |
|
find_all_cli_subcommands()
¶
Source code in kiara/utils/class_loading.py
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
|