Skip to content

Adds Zenodo data archival functionality#249

Open
nuest wants to merge 4 commits into
GeoinformationSystems:mainfrom
nuest:feature/zenodo-deposit
Open

Adds Zenodo data archival functionality#249
nuest wants to merge 4 commits into
GeoinformationSystems:mainfrom
nuest:feature/zenodo-deposit

Conversation

@nuest
Copy link
Copy Markdown
Member

@nuest nuest commented May 11, 2026

Enables automatic data package generation and deposition to Zenodo, ensuring long-term preservation and citability for OPTIMAP data.

This comprehensive feature introduces:

Data Package Generation

  • A render_zenodo command that builds essential artifacts: a dynamic README.md (generated from a Jinja2 template with live statistics and source information), an optimap-main.zip containing the project's source code snapshot, and a zenodo_dynamic.json file for flexible metadata updates.
  • This process also manages versioning via last_version.txt.

Zenodo Deposition Management

  • A deposit_zenodo command for updating existing Zenodo draft depositions. It intelligently merges metadata, protecting crucial identifiers like DOIs, and ensures a clean slate by deleting previous files before uploading new ones.
  • A combined zenodo_deposit command simplifies the workflow by executing both the rendering and deposition steps sequentially.

Logging, Monitoring, and Notifications

  • A new ZenodoDepositionLog model records every deposition attempt, tracking status, uploaded files, total size, duration, and any errors encountered.
  • This log is accessible and viewable in the Django admin, offering detailed insights into each archival event.
  • Staff users receive email notifications detailing the outcome of each deposition, including direct links to the Zenodo draft for review.
  • The /data public page now prominently displays information about the latest successful Zenodo deposition, with environment-aware display (sandbox in DEBUG, production otherwise).

Streamlined Administration

  • An admin action "Trigger Zenodo Deposition" is available for Works, allowing a full render and deposit cycle to be initiated directly from the admin interface.

Configuration

  • New settings (ZENODO_API_TOKEN, ZENODO_SANDBOX_DEPOSITION_ID, ZENODO_API_BASE) are introduced for flexible environment configuration, supported by a tests/.env.template.

Enhanced Testing

  • Includes dedicated unit tests for the rendering and deposition logic, alongside robust integration tests that run against the actual Zenodo sandbox API, ensuring reliable end-to-end functionality.

Relates to #63

nuest and others added 4 commits May 11, 2026 12:24
Implements functionality to deposit OPTIMAP data to Zenodo by creating/updating draft records. This feature enables automated archival and versioning of research data for long-term preservation and citation.

Features:
- Two Django management commands:
  - `render_zenodo`: Generates metadata files and data archives
  - `deposit_zenodo`: Uploads files and merges metadata to Zenodo drafts
- Updates existing drafts only (requires deposition ID)
- Never publishes automatically - manual approval required in Zenodo UI
- Uploads: README.md, optimap-main.zip, latest GeoJSON and GeoPackage files
- Merges metadata non-destructively without overwriting stable fields
- Configurable via environment variables (ZENODO_API_TOKEN, etc.)
- Comprehensive test coverage for rendering and deposition

New files:
- works/management/commands/deposit_zenodo.py - Upload to Zenodo
- works/management/commands/render_zenodo.py - Generate metadata/archives
- works/templates/README.md.j2 - Jinja2 template for README
- data/README.md, data/last_version.txt, data/zenodo_dynamic.json
- tests/test_deposit_zenodo.py - Deposition tests
- tests/test_render_zenodo.py - Render tests

Modified files:
- .gitignore - Ignore Zenodo artifacts
- optimap/settings.py - Add Zenodo configuration
- requirements.txt - Add zenodo-client, markdown, jinja2 dependencies

This implementation is adapted from PR #214 to work with the refactored
codebase (publications/ → works/ directory structure).

Closes ifgi#63

Co-authored-by: BharatVe <bharatveauli@live.com>
Co-authored-by: BharatVe <150399011+BharatVe@users.noreply.github.com>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Adds comprehensive integration test suite for Zenodo deposition functionality
with support for testing against the actual Zenodo sandbox API.

Changes:
- Fixed model references in tests (Publication → Work, publications → works)
- Added tests/.env.template with configuration instructions
- Created test_zenodo_integration.py with tagged integration tests
- Tests can run against real Zenodo sandbox API with proper credentials
- Added .env file to .gitignore to protect secrets

Test categories:
- Unit tests: Mock-based tests (existing)
- Integration tests: Real API tests (new, tagged as 'integration')
- Full deposit tests: End-to-end upload tests (tagged as 'slow' and 'upload')

Usage:
  # Run only unit tests (no API calls):
  python manage.py test tests.test_deposit_zenodo tests.test_render_zenodo

  # Run integration tests (requires tests/.env):
  python manage.py test tests.test_zenodo_integration

  # Run specific test tags:
  python manage.py test --tag=integration
  python manage.py test --exclude-tag=slow

Setup:
  1. Copy tests/.env.template to tests/.env
  2. Add Zenodo sandbox API token from https://sandbox.zenodo.org
  3. Create a draft deposition and add its ID to .env
  4. Run: python manage.py test tests.test_zenodo_integration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Implements automated data archival to Zenodo for long-term preservation and citability.

- Introduces a new `zenodo` app with functions for rendering metadata, depositing data, and managing Zenodo records.
- Creates new management commands (`render_zenodo`, `deposit_zenodo`, and `zenodo_deposit`) for simplified workflow.
- Adds a new `ZenodoDepositionLog` model to track deposition history and status.
- Enhances the Django admin interface with actions to trigger depositions and view logs.
- Includes comprehensive documentation in `README.md` on setting up and using the Zenodo integration.
Refs ifgi#63.

- untrack data/README.md, data/zenodo_dynamic.json, data/last_version.txt
  (sandbox render output from local runs leaked into the branch); extend
  .gitignore to cover them plus CSV dump variants
- fix the README.md.j2 sources loop — was unpacking dicts as (label, url)
  tuples so every entry rendered as "[name](url)" with no newline between
  items; iterate over Source dicts properly
- switch tests/test_deposit_zenodo.py and tests/test_render_zenodo.py from
  unittest.TestCase to django.test.TestCase so the in-test
  ZenodoDepositionLog.save() and ORM-created Source rows hit a real test
  DB instead of crashing (deposit) or polluting the dev DB (render)
- refresh the 0009 migration header timestamp
- CHANGELOG entry under Unreleased describing the deposit groundwork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant