oarepo_oaipmh_harvester.jobs
oarepo_oaipmh_harvester.jobs
invenio-jobs integration - one job type per harvester.
invenio-jobs supports run parameters only, not job parameters, so a single job type can
not be scheduled separately for different harvesters.
register_oaipmh_job therefore creates
a subclass of OAIHarvestJob with the id
harvest_oaipmh_records_<harvester id> for every harvester - when the harvester is
created and for all stored harvesters at application start
(register_current_harvesters).
invenio-jobs passes the start of the last successful run as since, so scheduled runs
are incremental.
OAIHarvestJob
Bases: JobType
OAI Harvester Job.
Source code in oarepo_oaipmh_harvester/jobs.py
id = 'harvest_oaipmh_records'
class-attribute
instance-attribute
ID is passed by the subclass when harvester is created.
Note: jobs do not have parameters, only run parameters, but we need to pass harvester_id and passing them as run parameters is not possible when scheduling the job from the administration interface. Because of that, we create a new subclass of this job for each harvester with the harvester code embedded in the job ID.
The id of the job is then "harvest_oaipmh_records_{harvester_id}" and this id is never used.
title = 'OAI Harvester Job'
class-attribute
instance-attribute
Title is passed by the subclass when harvester is created.
description = 'Harvester job for OAI-PMH Harvester'
class-attribute
instance-attribute
Description of the harvester job.
build_task_arguments(job_obj: Job, since: datetime | str | None = None, **kwargs: Any) -> dict
classmethod
Build task arguments for the job.
Source code in oarepo_oaipmh_harvester/jobs.py
register_oaipmh_job(harvester_id: str) -> None
Register a new OAI-PMH harvester job.
Note: current invenio-jobs does not support job parameters, only run parameters. Because harvesters are created dynamically in a database and each harvester needs its own job (otherwise it would not be possible to schedule them separately), we need to create a new job class for each harvester.
This is done dynamically whenever a new harvester is created or during server startup inside the finalize_apps function.
Source code in oarepo_oaipmh_harvester/jobs.py
get_oaipmh_job_id(harvester_id: str) -> str
get_oaipmh_job(harvester_id: str) -> Job
Get the job for the given harvester ID.
Source code in oarepo_oaipmh_harvester/jobs.py
unregister_oaipmh_job(job_id: str) -> None
register_current_harvesters() -> None
Register jobs for all harvesters stored in the database.