perago.load_module_task#
- perago.load_module_task(module_target)[源代码]#
Import a module target and return its single Perago task definition.
load_module_taskis the shared loader used byperago check,perago extract, and worker startup. The target must be a Python import path such as"app.workers.features_build". File paths, object paths, and modules that register zero or multiple tasks are rejected.- Parameters:
- module_targetstr
Python module import path that should contain exactly one
task()-decorated function.
- Returns:
- TaskDefinition
Validated task definition registered by the imported module.
- Raises:
- TaskDefinitionError
If
module_targetis not a module import path, cannot provide exactly one Perago task, or imports a task with an invalid contract.
- 参数:
module_target (str)
- 返回类型:
参见
taskDecorator that registers the task definition on import.
TaskDefinitionValidated contract returned by this loader.
Examples
>>> definition = load_module_task("app.workers.features_build") >>> definition.name 'features.build'