diff --git a/invenio_vocabularies/jobs.py b/invenio_vocabularies/jobs.py index 90d5cfe1..f5d358b5 100644 --- a/invenio_vocabularies/jobs.py +++ b/invenio_vocabularies/jobs.py @@ -9,42 +9,17 @@ """Jobs module.""" import datetime -from datetime import timezone from invenio_i18n import gettext as _ from invenio_jobs.jobs import JobType -from marshmallow import Schema, fields -from marshmallow_utils.fields import TZDateTime from invenio_vocabularies.services.tasks import process_datastream -class ArgsSchema(Schema): - """Schema of task input arguments.""" - - since = TZDateTime( - timezone=timezone.utc, - format="iso", - metadata={ - "description": _( - "YYYY-MM-DD HH:mm format. " - "Leave field empty if it should continue since last successful run." - ) - }, - ) - job_arg_schema = fields.String( - metadata={"type": "hidden"}, - dump_default="ArgsSchema", - load_default="ArgsSchema", - ) - - class ProcessDataStreamJob(JobType): """Generic process data stream job type.""" - arguments_schema = ArgsSchema task = process_datastream - id = None class ProcessRORAffiliationsJob(ProcessDataStreamJob): @@ -55,12 +30,9 @@ class ProcessRORAffiliationsJob(ProcessDataStreamJob): id = "process_ror_affiliations" @classmethod - def default_args(cls, job_obj, since=None, **kwargs): + def build_task_arguments(cls, job_obj, since=None, **kwargs): """Generate default job arguments here.""" - if since is None and job_obj.last_runs["success"]: - since = job_obj.last_runs["success"].started_at - else: - since = since or datetime.datetime.now() + since = since or datetime.datetime.now() # NOTE: Update is set to False for now given we don't have the logic to re-index dependent records yet. # Since jobs support custom args, update true can be passed via that. @@ -98,12 +70,9 @@ class ProcessRORFundersJob(ProcessDataStreamJob): id = "process_ror_funders" @classmethod - def default_args(cls, job_obj, since=None, **kwargs): + def build_task_arguments(cls, job_obj, since=None, **kwargs): """Generate default job arguments here.""" - if since is None and job_obj.last_runs["success"]: - since = job_obj.last_runs["success"].started_at - else: - since = since or datetime.datetime.now() + since = since or datetime.datetime.now() # NOTE: Update is set to False for now given we don't have the logic to re-index dependent records yet. # Since jobs support custom args, update true can be passed via that. diff --git a/setup.cfg b/setup.cfg index 96dd36d8..c2645cbc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,7 +30,7 @@ install_requires = invenio-i18n>=2.0.0,<3.0.0 invenio-records-resources>=6.0.0,<7.0.0 invenio-administration>=2.0.0,<3.0.0 - invenio-jobs>=1.0.0,<2.0.0 + invenio-jobs>=2.0.0,<3.0.0 lxml>=4.5.0 PyYAML>=5.4.1 regex>=2024.7.24