cli: Use temporary scheduler as fallback when no configuration detected

In order to simplify the testing of listers, allow to call the run command
of swh-lister CLI without scheduler configuration. In that case a temporary
scheduler instance with a postgresql backend is created and used.

It enables to easily test a lister with the following command:

$ swh -l DEBUG lister run <lister_name> url=<forge_url>
This commit is contained in:
Antoine Lambert 2023-06-22 14:36:13 +02:00
parent 7344d264e7
commit 7092e4e4ac
2 changed files with 9 additions and 1 deletions

View file

@ -1,2 +1,2 @@
swh.core[db,github] >= 2.22.0
swh.scheduler >= 0.8
swh.scheduler >= 1.12.0

View file

@ -69,6 +69,14 @@ def run(ctx, lister, options):
if options:
config.update(parse_options(options)[1])
if "scheduler" not in config:
logger.warning(
"No scheduler configuration detected, using a temporary instance "
"with postgresql backend instead."
)
config["scheduler"] = {"cls": "temporary"}
get_lister(lister, **config).run()