Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curation: add EURecordCuration job #1076

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions site/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ invenio_search.index_templates =
zenodo_rdm = zenodo_rdm.index_templates
idutils.custom_schemes =
edmo = zenodo_rdm.custom_schemes:get_scheme_config_func
invenio_jobs.jobs =
eu_records_curation = zenodo_rdm.curation.jobs:EURecordCuration

[bdist_wheel]
universal = 1
Expand Down
47 changes: 47 additions & 0 deletions site/zenodo_rdm/curation/jobs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2024 CERN.
#
# ZenodoRDM is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
"""Jobs module."""

from datetime import datetime, timezone

from invenio_i18n import lazy_gettext as _
from invenio_jobs.jobs import JobType
from marshmallow import Schema, fields
from marshmallow_utils.fields import ISODateString

from zenodo_rdm.curation.tasks import run_eu_record_curation


class ArgsSchema(Schema):
"""Schema of task input arguments."""

since = ISODateString()
job_arg_schema = fields.String(
metadata={"type": "hidden"},
dump_default="ArgsSchema",
load_default="ArgsSchema",
)


class EURecordCuration(JobType):
"""EU Record Curation Job."""

arguments_schema = ArgsSchema
yashlamba marked this conversation as resolved.
Show resolved Hide resolved
task = run_eu_record_curation
description = _("Curate published records for EU community")
title = _("EU Record Curation")
id = "eu_record_curation"

@classmethod
def default_args(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.now(timezone.utc)

return {"since": str(since)}