Skip to content
Snippets Groups Projects
Verified Commit b272a362 authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

core.lister_base: Refactor task creation

parent 3e3b4416
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ Build-Depends: debhelper (>= 9),
python3-setuptools,
python3-sqlalchemy (>= 1.0),
python3-swh.core,
python3-swh.scheduler (>= 0.0.30~),
python3-swh.scheduler (>= 0.0.31~),
python3-swh.storage,
python3-swh.storage.schemata,
python3-testing.postgresql,
......@@ -23,7 +23,7 @@ Homepage: https://forge.softwareheritage.org/source/swh-lister/
Package: python3-swh.lister
Architecture: all
Depends: python3-swh.scheduler (>= 0.0.30~),
Depends: python3-swh.scheduler (>= 0.0.31~),
${misc:Depends},
${python3:Depends}
Breaks: python3-swh.lister.github
......
swh.core
swh.storage[schemata] >= 0.0.76
swh.scheduler >= 0.0.30
swh.scheduler >= 0.0.31
......@@ -14,7 +14,7 @@ from sqlalchemy import create_engine, func
from sqlalchemy.orm import sessionmaker
from swh.core import config
from swh.scheduler import get_scheduler
from swh.scheduler import get_scheduler, utils
from swh.storage import get_storage
from .abstractattribute import AbstractAttribute
......@@ -392,7 +392,7 @@ class SWHListerBase(abc.ABC, config.SWHConfig):
'url': origin_url,
}
def task_dict(self, origin_type, origin_url):
def task_dict(self, origin_type, origin_url, **kwargs):
"""Return special dict format for the tasks list
Args:
......@@ -401,16 +401,9 @@ class SWHListerBase(abc.ABC, config.SWHConfig):
Returns:
the same information in a different form
"""
return {
'type': 'origin-update-%s' % origin_type,
'arguments': {
'args': [
origin_url,
],
'kwargs': {},
},
'next_run': utcnow(),
}
_type = 'origin-update-%s' % origin_type
_policy = 'recurring'
return utils.create_task_dict(_type, _policy, origin_url)
def string_pattern_check(self, a, b, c=None):
"""When comparing indexable types in is_within_bounds, complex strings
......@@ -473,7 +466,7 @@ class SWHListerBase(abc.ABC, config.SWHConfig):
)
if not ir.task_id:
ir.task_id = self.scheduler.create_tasks(
[self.task_dict(m['origin_type'], m['origin_url'])]
[self.task_dict(**m)]
)[0]['id']
def ingest_data(self, identifier, checks=False):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment