oarepo_oaipmh_harvester.tasks
oarepo_oaipmh_harvester.tasks
Harvest Celery tasks and datastream construction.
harvest_oaipmh_records loads a harvester and builds an invenio-vocabularies datastream from it:
- reader - the harvester's
loader(defaultoai-pmh, the invenio-vocabularies OAI-PMH reader), withbase_url,metadata_prefix,set,from_date(fromsince, formatted to the granularity the server advertises inIdentify, see format_oaipmh_datestamp) andidentifiersfilled in unless given in the loader options; - transformers and writers - the harvester's
transformers/writers.
Transformers and writers are wrapped by create_datastream - a failure of a single record is stored on its harvest record and the harvest continues.
Each definition is a string name{options} where options are a JSON5 object
(parse_config); harvester_id is always
added to the options. The names are looked up in VOCABULARIES_DATASTREAM_READERS /
_TRANSFORMERS / _WRITERS.
run_all_harvesters (job type RunAllHarvesters) runs a full harvest of all harvesters.
RunAllHarvesters
Bases: JobType
A job type to run invenio CLI commands as Celery tasks.
Source code in oarepo_oaipmh_harvester/tasks.py
format_oaipmh_datestamp(since: datetime | str, base_url: str) -> str
Format since as an OAI-PMH datestamp matching the server granularity.
OAI-PMH repositories that advertise YYYY-MM-DD granularity (e.g. the
ASEP ARL server) reject any time component, while ...+00:00 offsets
produced by datetime.isoformat() are illegal in both granularities.
Seconds-granularity servers get YYYY-MM-DDThh:mm:ssZ (UTC), others a
bare YYYY-MM-DD.
Source code in oarepo_oaipmh_harvester/tasks.py
harvest_oaipmh_records(*, harvester_id: str, oai_ids: list[str] | None = None, since: datetime | None = None, batch_size: int | None = None) -> None
Harvest OAI-PMH records for the given harvester, then mail a report to its harvest managers.
Source code in oarepo_oaipmh_harvester/tasks.py
parse_config(config: str) -> tuple[str, dict]
Parse a config string of the form type{args}.
Source code in oarepo_oaipmh_harvester/tasks.py
create_readers(harvester: OAIHarvesterAggregate, since: datetime | str | None = None, oai_ids: list[str] | None = None) -> dict
Create readers config for the harvester.
Source code in oarepo_oaipmh_harvester/tasks.py
create_transformers(harvester: OAIHarvesterAggregate) -> list[dict]
Create transformers config for the harvester.
Source code in oarepo_oaipmh_harvester/tasks.py
create_writers(harvester: OAIHarvesterAggregate) -> list[dict]
Create writers config for the harvester.
Source code in oarepo_oaipmh_harvester/tasks.py
run_all_harvesters() -> None
Run all OAI-PMH harvester tasks.