core.lister_base: Refactor task creation
This commit is contained in:
parent
3e3b441646
commit
b272a36237
3 changed files with 9 additions and 16 deletions
4
debian/control
vendored
4
debian/control
vendored
|
@ -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
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue