Skip to main content

CKAN License

ckanext-zenodo

Stores a dataset's large or non-tabular files on Zenodo instead of in CKAN's own storage, and publishes them there - with a DOI, in a Zenodo community - when the dataset is made public. The dataset stays a normal, searchable CKAN dataset: each Zenodo file appears in it as a resource linking to Zenodo, with a preview for images, audio and video. Built for the FAIR3R catalogue, whose FDF metadata it maps into the Zenodo record.

How it works

  • Routing: a file goes to Zenodo when it's larger than ckan.max_resource_size, or in a format the data viewer can't read (not in ckanext.xloader.formats), or when the user switches "Zenodo" on. Everything else stays in CKAN. (Without ckanext.xloader.formats, no format counts as readable, so every file goes to Zenodo.)
  • Upload: the browser sends the file to the CKAN server in 16 MB chunks (short requests, whatever the file's size), then the CKAN worker sends it into a draft Zenodo deposition kept for the dataset, by one shared Zenodo account. Nothing is public yet. A failed send keeps the file, is retried automatically, and the dataset page tells its editors (with Retry / Remove).
  • Publish: when the dataset is active and public, a background job writes the metadata, publishes the deposition (Zenodo mints a DOI), files it into the community and creates the CKAN resources.
  • Later changes: adding, replacing or deleting a file publishes a new version of the same record. Resources link to the record's concept DOI, which always resolves to the latest version.
  • Dataset deleted: unpublished Zenodo files are deleted with it; published ones stay on Zenodo (the user is told so).

The full specification is in docs/: architecture, every workflow step by step, metadata mapping, security, configuration and operations, and the Zenodo API behaviour it relies on.

Requirements

  • CKAN 2.12 with its Redis and background worker (ckan jobs worker) running - publishing and deletions run as background jobs.
  • A Zenodo account and a personal access token (Zenodo -> Applications -> Personal access tokens) allowed to create and publish depositions (deposit:write, deposit:actions). Use sandbox.zenodo.org for testing: it's a separate site, with its own account, token and community.
  • A Zenodo community, of which that account is owner, manager or curator (needed to accept each record into it).
  • Recommended: ckanext-fair3r (PyPI), for a richer upload form (several files at once, capacity badge), the "Publish" button, "Download all" and the FDF metadata in the Zenodo record. Not required: this plugin adds its own Zenodo switch to CKAN's "new resource" form. See Relationship to ckanext-fair3r.
  • Optional: ckanext-doi (PyPI: ckanext-fair3r-doi): the Zenodo record links back to the dataset's own DataCite DOI.

Installation

  1. Install the package in CKAN's virtualenv:

    pip install ckanext-zenodo
    
  2. Enable the plugin, with CKAN's view plugins used for the previews, in ckan.ini:

    ckan.plugins = ... zenodo image_view audio_view video_view
    
  3. Configure the Zenodo account (sandbox here; for zenodo.org set test_mode = false and ckanext.zenodo.access_token instead):

    ckanext.zenodo.test_mode = true
    ckanext.zenodo.sandbox_access_token = <token>
    ckanext.zenodo.community_identifier = fair3r
    

    Every other setting has a default - see docs/operations.md.

  4. Create the table:

    ckan -c /path/to/ckan.ini db upgrade -p zenodo
    
  5. Retry failed publishes every 30 minutes, as the CKAN user (cron):

    */30 * * * * /path/to/venv/bin/ckan -c /path/to/ckan.ini zenodo retry-pending
    
  6. Disk and proxy: each file is assembled under ckan.storage_path before being sent on, so the server needs up to ckanext.zenodo.max_file_size_bytes (10 GB by default) free on top of ckanext.zenodo.disk_safety_margin_bytes (5 GB). Chunks are 16 MB, so a reverse proxy's usual 20 MB body limit is enough (only the older single-request route, /zenodo/upload/, needs a larger one).

  7. Restart CKAN and its worker, then check the setup against Zenodo:

    ckan -c /path/to/ckan.ini zenodo check
    

    It verifies the token, its access to depositions, the community and the account's role in it, and exits 1 on the first problem.

Commands

Command Use
ckan zenodo check Verify the token and community against Zenodo
ckan zenodo retry-pending [--include-failed] Re-queue failed publishes (cron). Gives up after ckanext.zenodo.max_publish_attempts (10) unless --include-failed
ckan zenodo disk-reservations show / clear Disk space reserved by uploads in flight / reset it after a crashed worker

Relationship to ckanext-fair3r

Not a dependency: the plugin works on its own, but ckanext-fair3r is recommended, and is what this plugin was built for. What changes with and without it:

  • Upload form. Without ckanext-fair3r, CKAN's "new resource" form gets a built-in "Store this file on Zenodo" switch and a progress bar: one file at a time, sent to this plugin's /zenodo/upload/<dataset> endpoint when it belongs on Zenodo (see Routing), posted with the form as usual otherwise. With ckanext-fair3r enabled, its own resource form takes over instead (the built-in one is not rendered), and adds several files at once, the live capacity badge and a warning when a file name already exists. Any other client can also POST to the endpoint.
  • Around the form. ckanext-fair3r provides the "Publish" button and "Download all", which uses Zenodo's own ZIP for Zenodo files. Without it, a dataset is published by making it public (Manage -> Visibility).
  • Metadata. This plugin converts the dataset's FDF metadata with ckanext-fair3r's DataCite converter (optional import). Without it, a record is still published, with minimal metadata (title, tags, licence, submitter).

Tests

docker exec -u ckan -it ckan-app pytest --ckan-ini=/plugins/ckanext-zenodo/test.ini /plugins/ckanext-zenodo/ckanext/zenodo/tests

Always pass --ckan-ini: the test fixtures empty the database they run against, and refuse to run unless its name contains test. The test.ini at the repository root is for the DEV container; ckanext/zenodo/tests/test.ini, shipped in the package, is the one the integration server uses - keep their plugin lists in sync.

License

Released under the GNU Affero General Public License (AGPL) v3.0. See the file LICENSE for details.

Metadata

Release files for ckanext-zenodo 0.1.30

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ckanext-zenodo 0.1.30
File Size Uploaded Provenance Actions
ckanext_zenodo-0.1.30.tar.gz 125.8 kB Without provenance Details for ckanext_zenodo-0.1.30.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ckanext-zenodo 0.1.30
File Interpreter ABI Platform Actions
ckanext_zenodo-0.1.30-py3-none-any.whl Python 3 none any Details for ckanext_zenodo-0.1.30-py3-none-any.whl

Total release size: 280.2 kB

Release files / ckanext_zenodo-0.1.30.tar.gz

Download URL ckanext_zenodo-0.1.30.tar.gz
Size 125.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d7a9c8b9cd0b65f6869ef319568e5342e537a33313eda16df7e37f45c2fb5ac9
BLAKE2b-256 checksum
How to use checksums
c4915ecc4f1fd3729212d4646059184a68af0fd729e4f0bfca3f4e751d9d3bbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Release files / ckanext_zenodo-0.1.30-py3-none-any.whl

Download URL ckanext_zenodo-0.1.30-py3-none-any.whl
Size 154.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fea3db58404bd654f1da829866f1a3f5cc4bc5ac98be6366cea5f4164436b33
BLAKE2b-256 checksum
How to use checksums
46a59c4b92020370b74e425eaf00ff9c79818fc52f843de52886f850b7a62e61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Security for ckanext-zenodo 0.1.30

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page