Skip to main content

OAIPMH harvester

Project description

OARepo OAI-PMH harvester

An OAI-PMH harvesing library for Invenio 3.5+. The library provides initial transformation of OAI-PMH payload to an intermediary json representation which is later on transformed by a specific transformer to the format of invenio records.

Due to their generic nature, these transformers are not part of this library but have to be provided by an application.

The progress and transformation errors are captured within the database.

For now, the library does not provide error notifications, but these will be added. Sentry might be used for the logging & reporting.

Installation

pip install oarepo-oaipmh-harvester
pip install <your transformer library>

Configuration

All configuration is inside the OAIHarvesterRecord record. There is a command-line tool to add a new record:

invenio oarepo oai harvester add nusl \
    --name "NUSL harvester" \
    --url http://invenio.nusl.cz/oai2d/ \
    --set global \
    --prefix marcxml \
    --loader sickle \
    --transformer marcxml \
    --transformer nusl \
    --writer 'service{service=nr_documents}'

This will register an oai-pmh harvester with code "nusl", its url, oai set and metadata prefix. Records from this harvester will be loaded with the sickle loader (default loader if not specified) and at first transformed from marcxml to json format and subsequently by NUSL transformer to get nr_documents compatible json.

The json is then used by service writer to create/update the target record.

Usage

Command-line

On command line, invoke

invenio oarepo oai harvester run nusl <optional list of oai identifiers to harvest>

Options:

  --all-records      Re-harvest all records, not from the last timestamp
  --on-background    Run harvest on background (via celery task)
  --identifier       Harvest the passed identifier/s

You can also pass arguments for "havester add" to override the defaults from the configuration.

Harvest status

Harvester uses 3 additional types of record:

  • Run represents a single run of the harvester
  • Batch - the run consists of multiple batches, that is records, that are processed together. Each such batch is represented in the batch record
  • OAI record is a link between harvested record and its original. If there are errors harvesting the record, it is still created and its errors field is filled with the error

Custom parsers and transformers

Transformer

A piece of code that gets a StreamEntry (or a StreamBatch) instance, processes it and returns modified StreamEntry. An example is a MarcXML transformer that takes the string with xml representation of the entry and transforms it into simple json representation {abcxy: value(s)}, where abcxy is marc field code.

See oarepo_runtime.datastream.transformers package for StreamEntry/StreamBatch interfaces.

The transformer needs to be registered:

# mypkg.transformers

from .impl import MyTransformer

my_transformer = {"class": MyTransformer, "params": {
       # default parameters that will go to the MyTransformer constructor
}}

And setup.cfg:

# setup.cfg

[options.entry_points]
oarepo.oaipmh.transformers =
    my_transformer = mypkg.transformers:my_transformer

Then you can use my_transformer when creating your harvester.

Reader

A reader is responsible for fetching records and creating a stream of StreamEntry items. See oarepo_runtime.datastreams.readers for details. Then register the reader into oarepo.oaipmh.readers entry point with the same syntax as above.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oarepo_oai_pmh_harvester-4.1.3.tar.gz (109.3 kB view details)

Uploaded Source

Built Distribution

oarepo_oai_pmh_harvester-4.1.3-py3-none-any.whl (199.9 kB view details)

Uploaded Python 3

File details

Details for the file oarepo_oai_pmh_harvester-4.1.3.tar.gz.

File metadata

File hashes

Hashes for oarepo_oai_pmh_harvester-4.1.3.tar.gz
Algorithm Hash digest
SHA256 03a5892953cb4a678c2ea08839f98e34068f0a0ef09acaa0b1a30e6a74438da1
MD5 3e09b972e972e8421641ed6f5607ed0b
BLAKE2b-256 376afe2673a288cca78136ea513217596b8f090f821fd998a82092155dd1405b

See more details on using hashes here.

File details

Details for the file oarepo_oai_pmh_harvester-4.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for oarepo_oai_pmh_harvester-4.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6f59e85cbc40f75d3eac8662eaa32b145eaa3d59f36034efe9fa2d4652e78fcd
MD5 1309892ac95aea3f763a6fa366ed4176
BLAKE2b-256 c4180937b8122eec0e1ecfd8d91eaf00e4b93a98c8f7902a48a562e77bd45460

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page