Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d40251e
Publish project snapshots to zenodo
Oct 18, 2024
a8a37b4
Enhance Zenodo Export Provider
Oct 18, 2024
877ce86
refactor: split exports and add publish provider
MyPyDavid Oct 17, 2024
0c67ec7
docs: fix url for zenodo-publish
MyPyDavid Oct 17, 2024
19aaf8d
fix: add class attribute for RDMO_PLUGIN_KEY
MyPyDavid Oct 18, 2024
3d04c95
feat,fix: add RDMO_PLUGIN_KEY and methods for pdf from snapshot upload
MyPyDavid Oct 18, 2024
0c5d4a8
feat: add functions for zenodo api upload
MyPyDavid Oct 25, 2024
571a980
build: autoupdate pre-commit
MyPyDavid Oct 25, 2024
ae73bae
chore: remove breakpoint
MyPyDavid Oct 25, 2024
99ea1d3
refactor: rename to export_dataset
MyPyDavid Nov 4, 2024
3bfaef7
build: update ruff.lint config
MyPyDavid Nov 4, 2024
f326385
feat: add zenodo urls to base
MyPyDavid Nov 4, 2024
c7eef4e
feat: add ZenodoMetadataExport class in metadata.py
MyPyDavid Nov 4, 2024
84f1c1b
feat: add authorized json headers and rename to records url
MyPyDavid Nov 4, 2024
a452b5f
refactor: move forms to forms.py
MyPyDavid Nov 4, 2024
3910fc7
refactor: rename to records url
MyPyDavid Nov 4, 2024
2a617cc
feat: add publication and versioning workflow to provider
MyPyDavid Nov 4, 2024
ac3ace1
refactor: move rdmo db methods to utils.py
MyPyDavid Nov 4, 2024
fa589c9
feat: add optional zenodo record url to export template
MyPyDavid Nov 4, 2024
82beed1
use plugin.key instead
MyPyDavid Jul 25, 2025
a641b2c
refactor metadata into package with builder classes
MyPyDavid Jul 28, 2025
f216d40
add view and export format to snapshot form
MyPyDavid Jul 28, 2025
9c289ad
add publication type and define resource and upload types
MyPyDavid Jul 28, 2025
ac51f25
use metadata builder in get post data
MyPyDavid Jul 28, 2025
bcf4776
add view and format selection and use metadata builder in get post data
MyPyDavid Jul 28, 2025
bb10309
clean up utils and handle exceptions
MyPyDavid Jul 28, 2025
e94879f
revert exports template and add one for publish
MyPyDavid Jul 28, 2025
b2a96ce
docs: add InvenioRDM sanbdox
MyPyDavid Aug 6, 2025
dfcaf59
add config for url, attribute and scope and support for InvenioRDM
MyPyDavid Aug 6, 2025
17e8c30
rename metadata builder classes
MyPyDavid Aug 6, 2025
012693c
set default for zenodo_url and add to readme config
MyPyDavid Aug 6, 2025
627f8f5
style(docs): reorder config
MyPyDavid Aug 6, 2025
ee58804
docs: update config comments
MyPyDavid Aug 6, 2025
53de9d5
use zenodo_record_id_uri as setting instead of prefix and key
MyPyDavid Aug 7, 2025
53dfc25
re-implement metadata for zenodo and invenio
MyPyDavid Oct 9, 2025
91a701f
fix export to zenodo
MyPyDavid Oct 9, 2025
5d4aa90
docs: update README
MyPyDavid Oct 9, 2025
59377ff
update Provider classes and use get_metadata
MyPyDavid Oct 9, 2025
bcfafd7
build: add attrs and cattrs to deps
MyPyDavid Oct 9, 2025
e2d0744
fix metadata schemas
MyPyDavid Oct 13, 2025
cd99917
handle auth error and refactor get_metadata
MyPyDavid Oct 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
hooks:
- id: check-hooks-apply
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-ast
- id: check-yaml
Expand All @@ -15,7 +15,7 @@ repos:
- id: trailing-whitespace
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
rev: v0.7.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
64 changes: 46 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

This plugin implements an [export provider](https://rdmo.readthedocs.io/en/latest/plugins/index.html#export-providers) for RDMO, which lets users push metadata from RDMO to Zenodo work packages. The plugin uses [OAUTH 2.0](https://oauth.net/2/), so that users use their respective accounts in both systems. It creates only the metadata in Zenodo, so that users need to upload the actual data on Zenodo themselfes.

Setup
-----
## Setup

Install the plugin in your RDMO virtual environment using pip (directly from GitHub):

Expand All @@ -21,25 +20,45 @@ Add the plugin to `PROJECT_EXPORTS` in `config/settings/local.py`:

```python
PROJECT_EXPORTS += [
('zenodo', _('Directly to Zenodo'), 'rdmo_zenodo.exports.ZenodoExportProvider')
('zenodo', _('Directly to Zenodo'), 'rdmo_zenodo.exports.ZenodoExportProvider'),
('zenodo-publish', _('Publish to Zenodo'), 'rdmo_zenodo.exports.ZenodoPublishProvider')
]
```
When the translation method `_` was not yet imported in your `config/settings/local.py`, then add it this import at the top:
```
from django.utils.translation import gettext_lazy as _
```

## Configuration

### Register a *Developer application* for authentication

An *Developer applications* has to be registered with Zenodo here: https://zenodo.org/account/settings/applications/. For development, you can also use the sandbox instance provided by Zenodo: https://sandbox.zenodo.org/account/settings/applications/. During the registration, you need to enter a **Redirect URI** for your RDMO instance:
A *Developer applications* has to be registered with Zenodo here: https://zenodo.org/account/settings/applications/.
For development, you can also use the sandbox instance provided by Zenodo: https://sandbox.zenodo.org/account/settings/applications/.
Or for development against an InvenioRDM Instance the sandbox https://inveniordm.web.cern.ch/ can be used.
During the registration, you need to enter a **Redirect URI** for your RDMO instance:

```
https://rdmo.example.com/services/oauth/zenodo/callback/
http://localhost:8000/services/oauth/zenodo/callback/ # for development
https://rdmo.example.com/services/oauth/zenodo-publish/callback/

# or for local development
http://localhost:8000/services/oauth/zenodo/callback/
http://localhost:8000/services/oauth/zenodo-publish/callback/
```

After registration, you are provided with a `client_id` and a `client_secret`, which need to be added to the RDMO settings, along with some other optional entries:
### Configure the RDMO settings
After registration, you are provided with a `client_id` and a `client_secret`,
which need to be added to the RDMO settings in `config/settings/local.py`, along with some other optional entries:

```python
ZENODO_PROVIDER = {
'client_id': os.getenv('ZENODO_CLIENT_ID'),
'client_secret': os.getenv('ZENODO_CLIENT_SECRET'),
'add_project_members': True, # add the members of the project as creators to each dataset
'resource_type': 'dataset', # specify the resource type
'client_secret': os.getenv('ZENODO_CLIENT_SECRET'),
'zenodo_url': 'https://zenodo.org', # optional, default shown here , or your own InvenioRDM instance url
'zenodo_auth_scope': 'deposit:write', # optional, default shown here or 'user:email' for InvenioRDM
'zenodo_record_id_uri': 'https://rdmorganiser.github.io/terms/project/metadata/publication/zenodo/record_id', # optional, default is shown here
'add_project_members': True, # add the members of the project as creators to exported record
'language': 'eng', # specify the language
'publisher': '', # specify the publisher
'funding': [ # specify funding information
Expand All @@ -63,18 +82,27 @@ ZENODO_PROVIDER = {
]
}
```
The `resource_type` will be set by the specific export provider, e.g. as `'dataset'` or as `'publication-datamanagementplan'` for `zenodo-publish` export.

Usage
-----
## Usage

The plugins apears as export options on the RDMO project overview.
The plugins appear as export options on the RDMO project overview. For a Zenodo backend, it was tested against https://sandbox.zenodo.org/.
Analogous to Zenodo this plugin can also be used with InvenioRDM instances for which it was tested against https://inveniordm.web.cern.ch/.

Currently, the following properties of the Zenodo data model are created from RDMO attributes:

| Zenodo field | RDMO attribute |
| ------------- | ---------------------------------------------------------------------------------|
| `title` | `project/dataset/title` or `project/dataset/id` or `f'Dataset #{set_index + 1}'` |
| `description` | `project/dataset/description` |
| `rights` | `project/dataset/sharing/conditions` |

| Zenodo field | RDMO attribute |
|-----------------------|-----------------------------------------------------------------------------------------------------------------------|
| `title` | `project/dataset/title` or `project/dataset/id` or `f'Dataset #{set_index + 1}'` or `project.title` or `snapshot.title` |
| `description` | `project/dataset/description` |
| `license` or `rights` | `project/dataset/sharing/conditions` |
| `subjects` | `project/research_question/keywords` |
| `creators` | from `project.member` |
In addition, several fields can be configured in the settings as shown above.

### Development
Information about the API schemas can be found at:
* https://inveniordm.docs.cern.ch/reference/metadata/#metadata
* https://github.com/inveniosoftware/invenio-rdm-records/tree/master/invenio_rdm_records/records/jsonschemas/records
* https://zenodraft.github.io/metadata-schema-zenodo/latest/schema.json
* https://developers.zenodo.org/#depositions
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ classifiers = [
]
dependencies = [
"rdmo",
"attrs",
"cattrs",
]
dynamic = ["version"]

Expand All @@ -55,6 +57,8 @@ version = {attr = "rdmo_zenodo.__version__"}
[tool.ruff]
target-version = "py38"
line-length = 120

[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
Expand All @@ -74,7 +78,7 @@ ignore = [
"RUF012", # mutable-class-default
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
section-order = [
"future",
"standard-library",
Expand All @@ -87,7 +91,7 @@ section-order = [
"local-folder"
]

[tool.ruff.isort.sections]
[tool.ruff.lint.isort.sections]
pytest = ["pytest"]
django = ["django"]
rest_framework = ["rest_framework"]
Expand Down
201 changes: 0 additions & 201 deletions rdmo_zenodo/exports.py

This file was deleted.

2 changes: 2 additions & 0 deletions rdmo_zenodo/exports/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .export import ZenodoExportProvider as ZenodoExportProvider
from .publish import ZenodoPublishProvider as ZenodoPublishProvider
Loading