Pyscicat is python client for working with the SciCat API, which provides an easy mechanism to ingest data. See https://www.scicatproject.org/pyscicat/howto/ingest.html to get started.
For an example of the full workflow, please see the pyscicat.ipynb Jupyter notebook in SciCat live: https://github.com/SciCatProject/scicatlive/blob/main/services/jupyter/config/notebooks/pyscicat.ipynb. This includes how to authenticate, create a dataset, add datablocks and upload an attachment.
The following steps will add a dataset to your system using the API with the Linux program curl.
Login to the backend. The default password for the ingestor user is aman. Running the command below in the terminal will yield an access token.
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"username":"ingestor", "password":"<your_password>"}' 'http://localhost:3000/api/v3/Users/login'
Create a json file with the contents below and name it metadata.json
{
"creationLocation": "/PSI/SLS/TOMCAT",
"sourceFolder": "/scratch/devops",
"type": "raw",
"ownerGroup":"p16623"
}
cat the metadata.json file and pipe it to a curl command. Insert your access token in the command below and run it in the terminal:
cat metadata.json | curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d @- 'http://localhost:3000/api/v3/Datasets?access_token=YOUR_TOKEN_HERE'
There should now be a dataset in your mongoDB instance.
For site specific examples see the following links:
- ESS
- PSI In future to move to https://data-catalog-services.pages.psi.ch