Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/mercurial/tasks.py
# Copyright (C) 2017-2018 The Software Heritage developers | # Copyright (C) 2017-2018 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from celery import current_app as app | from celery import shared_task | ||||
from .loader import HgBundle20Loader, HgArchiveBundle20Loader | from .loader import HgBundle20Loader, HgArchiveBundle20Loader | ||||
@app.task(name=__name__ + '.LoadMercurial') | @shared_task(name=__name__ + '.LoadMercurial') | ||||
anlambert: Why the `(*, ` notation here ? | |||||
Done Inline ActionsTo force the use of kwargs in the tasks. ardumont: To force the use of kwargs in the tasks. | |||||
Not Done Inline ActionsOh I see, should the same behavior be ensured in other loader tasks ? anlambert: Oh I see, should the same behavior be ensured in other loader tasks ? | |||||
Done Inline ActionsYes, i think so. Though there comes the issue of migration (at least for recurring tasks ;) ardumont: Yes, i think so.
Though there comes the issue of migration (at least for recurring tasks ;) | |||||
def load_mercurial(origin_url, directory=None, visit_date=None): | def load_mercurial(*, url, directory=None, visit_date=None): | ||||
Not Done Inline ActionsJust curious, why using @shared_task here as @app.task is used in the other loaders ? anlambert: Just curious, why using `@shared_task` here as `@app.task` is used in the other loaders ? | |||||
Done Inline ActionsTo stop importing the scheduler's app state. That's what we do in lister and loader-core's tasks. I'm just aligning as i go along (if i see it ;) ardumont: To stop importing the scheduler's app state.
We had issues with that up to the point we stop… | |||||
Not Done Inline ActionsAck, you should do the same for the git and svn loader then. anlambert: Ack, you should do the same for the git and svn loader then. | |||||
Done Inline ActionsIndeed. I possibly missed them. ardumont: Indeed.
I possibly missed them. | |||||
"""Mercurial repository loading | """Mercurial repository loading | ||||
Import a mercurial tarball into swh. | Import a mercurial tarball into swh. | ||||
Args: see :func:`DepositLoader.load`. | Args: see :func:`DepositLoader.load`. | ||||
""" | """ | ||||
loader = HgBundle20Loader() | loader = HgBundle20Loader( | ||||
return loader.load(origin_url=origin_url, | url, directory=directory, visit_date=visit_date) | ||||
directory=directory, | return loader.load() | ||||
visit_date=visit_date) | |||||
@app.task(name=__name__ + '.LoadArchiveMercurial') | @shared_task(name=__name__ + '.LoadArchiveMercurial') | ||||
def load_archive_mercurial(origin_url, archive_path, visit_date=None): | def load_archive_mercurial(*, url, archive_path=None, visit_date=None): | ||||
"""Import a mercurial tarball into swh. | """Import a mercurial tarball into swh. | ||||
Args: see :func:`DepositLoader.load`. | Args: see :func:`DepositLoader.load`. | ||||
""" | """ | ||||
loader = HgArchiveBundle20Loader() | loader = HgArchiveBundle20Loader( | ||||
return loader.load(origin_url=origin_url, | url, archive_path=archive_path, visit_date=visit_date) | ||||
archive_path=archive_path, | return loader.load() | ||||
visit_date=visit_date) |
Why the (*, notation here ?