---
# System prepended metadata

title: RENKU EAWAG Dataset Export/Import

---

# RENKU EAWAG Dataset Export/Import

To empower users working with Renku from EAWAG, it would be helpful to support importing/exporting Renku Datasets from/to ERIC, EAWAG's data repository.

ERIC is based on CKAN and exposes the standard CKAN API, so writing a Renku CLI plugin that can interface with CKAN should suffice and covers a broader use-case than purely ERIC.

## Auth
Auth for the CKAN API is done using normal tokens passed in the `Authorization:` header. It is unclear whether/how EAWAG users have access to generate tokens for themselves at this point. Tokens aren't needed for public datasets

## Importing

Importing should be pretty straightforward:

- If DOI: Get dataset URL from DOI
- Get dataset name from URL
- get dataset metadata from [https://opendata.eawag.ch/api/3/action/package_show?id=<dataset_name>](https://docs.ckan.org/en/2.9/api/#ckan.logic.action.get.package_show)
- Convert to Renku metadata
- Download files from `resources[].url`


CKAN also supports JSON-LD, accessed using `<dataset-url>.jsonld`, but this requires the `ckanext-dcat` extension to be installed, which doesn't seem to be the case for EAWAG. Since we can't count on this being installed, it's probably better to just use the regular API.


## Exporting

Exporting likewise is pretty straightforward

- create a new package using [https://opendata.eawag.ch/api/3/action/package_create](https://docs.ckan.org/en/2.9/api/#ckan.logic.action.create.package_create) with `state: draft`, mapping our metadata as appropriate
    - note that `state:draft` is currently not actually supported on that endpoint: https://github.com/ckan/ckan/issues/5497
    - We might need to call `package_update` endpoint to update `state` to `draft` as long as this is not fixed
- Upload each file to the dataset using [https://opendata.eawag.ch/api/3/action/resource_create](https://docs.ckan.org/en/2.9/api/#ckan.logic.action.create.resource_create)
- inform the user of the name and/or URL of the created dataset, so they can manage/publish it in the ERIC UI

We might also want to support `--publish` flag in the CLI, changing the `state` from `draft` to `active` once all files are uploaded, though this depends on if we can fill all necessary fields for a dataset for EAWAG and if they're ok with this.


## Open Questions

- How would users get API tokens?
- Can we publish finalized datasets?
- Could we use the .jsonld URL for dataset? Can we get the plugin installed?
- Is opendata.eawag.ch the only instance or is there a private version of ERIC as well? If so, how does it differ and does the above approach need to be modified?
- How is versioning handled on CKAN? There's a `version` field but it's not clear if different versions of a dataset need to be tied together in some way or if this happens incidentally through reuse of the same id.