Skip to content

Commit

Permalink
jobs: add import awards OpenAIRE; Update CORDIS
Browse files Browse the repository at this point in the history
  • Loading branch information
yashlamba authored and ptamarit committed Oct 15, 2024
1 parent 307728d commit 388e6b8
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
63 changes: 63 additions & 0 deletions invenio_vocabularies/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,66 @@ def default_args(cls, job_obj, since=None, **kwargs):
"transformers": [{"type": "ror-funders"}],
}
}


class ImportAwardsOpenAIREJob(ProcessDataStreamJob):
"""Import awards from OpenAIRE registered task."""

description = "Import awards from OpenAIRE"
title = "Import Awards OpenAIRE"
id = "import_awards_openaire"

@classmethod
def default_args(cls, job_obj, **kwargs):
"""Generate default job arguments."""
return {
"config": {
"readers": [
{
"type": "openaire-http",
"args": {"origin": "diff", "tar_href": "/project.tar"},
},
{
"type": "tar",
"args": {
"mode": "r",
"regex": "\\.json.gz$",
},
},
{"type": "gzip"},
{"type": "jsonl"},
],
"transformers": [{"type": "openaire-award"}],
"writers": [
{"args": {"writer": {"type": "awards-service"}}, "type": "async"}
],
}
}


class UpdateAwardsCordisJob(ProcessDataStreamJob):
"""Update awards from CORDIS registered task."""

description = "Update awards from CORDIS"
title = "Update Awards CORDIS"
id = "update_awards_cordis"

@classmethod
def default_args(cls, job_obj, **kwargs):
"""Generate default job arguments."""
return {
"config": {
"readers": [
{"args": {"origin": "HE"}, "type": "cordis-project-http"},
{"args": {"mode": "r", "regex": "\\.xml$"}, "type": "zip"},
{"args": {"root_element": "project"}, "type": "xml"},
],
"transformers": [{"type": "cordis-award"}],
"writers": [
{
"args": {"writer": {"type": "cordis-awards-service"}},
"type": "async",
}
],
}
}
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ invenio_celery.tasks =
invenio_jobs.jobs =
process_ror_affiliations = invenio_vocabularies.jobs:ProcessRORAffiliationsJob
process_ror_funders = invenio_vocabularies.jobs:ProcessRORFundersJob
import_awards_openaire = invenio_vocabularies.jobs:ImportAwardsOpenAIREJob
update_awards_cordis = invenio_vocabularies.jobs:UpdateAwardsCordisJob

[build_sphinx]
source-dir = docs/
Expand Down

0 comments on commit 388e6b8

Please sign in to comment.