Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This short tutorial shows how to store data into the property service with python and requests

For IDL you can take a similar rout by adapting these instructions to Access to REST-Services in IDL

Routes

First of all we have to know which routes we need to use. For this it is recommended to take a look at the query builder or swagger ui (http://localhost:8002/ui/). Under the Edit tab there are all routes which can be used to insert or update data of the property service.

...

  • /provenance
  • /region/{provenance}

Requests

These two routes are both POST routes which requires them to be called with a POST request. To create simple post requests we recommend the python package requests.

...

Code Block
languagepy
r = requests.post("http://httpbin.org/post", json = {"key":"value"})

Implementation

Prepare

First of all you have to define the data you would like to store into the property service. In our example we are going to store some machine learning results into the provenance ml-algorithms.

...

Code Block
languagepy
# define data to store
post_data = {
    'time_start': '2016-01-21T17:27:59.001Z',
    'data': ml_result
}

Ingest

Now the ingest of this post_data is very simple. We first have to add the new provenance to the property service and then add a new region.

...

The addresses of the routes are the same we looked up before.

Retrieve

Now to check if everything worked we should retrieve all the properties which are stored under this provenance. This can be done with a GET request.

Code Block
languagepy
# retrieving data
print('downloading all properties...')
ml_properties = requests.get("http://localhost:8002/property/%s/list" % ml_provenance).json()

print(ml_properties)

Source Code

Here you can download the full python source code.

...