Exemple #1
0
def configure_task(
    app: procrastinate.App,
    task_name: str,
    configure_kwargs: Dict[str, Any],
    allow_unknown: bool,
) -> jobs.JobDeferrer:
    return app.configure_task(name=task_name,
                              allow_unknown=allow_unknown,
                              **configure_kwargs)
Exemple #2
0
def configure_job(
    app: procrastinate.App,
    task_name: str,
    configure_kwargs: Dict[str, Any],
    unknown: bool,
) -> jobs.JobDeferrer:
    app.perform_import_paths()
    try:
        return app.tasks[task_name].configure(**configure_kwargs)

    except KeyError:
        if unknown:
            return app.configure_task(name=task_name, **configure_kwargs)
        else:
            raise click.BadArgumentUsage(f"Task {task_name} not found.")