perago.load_module_task#

perago.load_module_task(module_target)[源代码]#

Import a module target and return its single Perago task definition.

load_module_task is the shared loader used by perago 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_target is not a module import path, cannot provide exactly one Perago task, or imports a task with an invalid contract.

参数:

module_target (str)

返回类型:

TaskDefinition

参见

task

Decorator that registers the task definition on import.

TaskDefinition

Validated contract returned by this loader.

Examples

>>> definition = load_module_task("app.workers.features_build")
>>> definition.name
'features.build'