This proxy creates a notebook in Google Collab from a template. The parameters extracted from the Scicence on Schema JSON-LD files, and sent to the proxy /mknb
For testing, running locally works well.
In production, a container is utilized. This is created by a github workflow, (containerize.yaml)
http://localhost:3031/ should return the index.html
http://localhost:3031/alive/ will let you know it's working.
http://localhost:3031/mknb/ This proxy creates a notebook in Google Collab from a template. The parameters extracted from the Scicence on Schema JSON-LD files, and sent to the proxy /mknb
- url - url of the resource
- ext - encoding format of the resource.
- urn - urn geocodes urn.
- template -- name of the template file to render. (optional: default: template.ipynb)
Note about url, urns, ext: A hash in the name of the item causes the rest of the url passed to be ignored. To avoid this, we custom encode '#' as <hash>
so:
ext=http://linked.earth/ontology/core/1.2.0/index-en.html#Dataset
becomes:
ext=http://linked.earth/ontology/core/1.2.0/index-en.html<hash>Dataset
several forms can be returned
http://localhost:3031/get_graph/{URN}/jsonld
http://localhost:3031/get_graph/{URN}/framed
http://localhost:3031/get_graph/{URN}/compact
http://localhost:3031/get_graph/{URN}/csv
http://localhost:3031/get_graph/{URN}/tsv
python -m pip install -e ec ../earthcube_utilities
python -m pip install -e bar @ git+https://github.com/earthcube/earthcube_utilities.git
python -m pip install -e ec /path/to/earthcube_utilities
In order to use oauth, you need to setup a github app, and set the following environment variables
GITHUB_OAUTHSECRET = GITHUB APP Secret GITHUB_OAUTHCLIENTID = GIHUB Client ID
cd src/notebook_proxy
flask mknb
this will start it at: http://localhost:5000/
cd src/notebook_proxy
python mknb.py
A docker container is built using github actions:
https://hub.docker.com/repository/docker/nsfearthcube/mknb
Note need to update to https://github.com/tiangolo/uwsgi-nginx-flask-docker
before use you need a token:
- go to settings>developer settings.
- personal access token
- create a token with gist permissions.
docker pull nsfearthcube/mknb:latest
docker run -e GITHUB_CLIENTID={GITHUB OAUTH APP} -e GITHUB_SECRET={GITHUB OAUTH APP SECRET} -p 127.0.0.1:3031:3031 nsfearthcube/mknb:latest
Need notes here.
You can build locally from the earthcube_utilities directory
% docker build .
% docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 1f0ebd17e990 22 minutes ago 959MB
image id is: 1f0ebd17e990
docker run -e GIST_TOKEN={YOUR TOKEN} -e GIST_USERNAME={YOU USERNAME} -p 127.0.0.1:3031:3031 {image id}
Proxy is now running at: http://localhost:3031/