Version 2.1 by chaney08 on 2021/06/22 19:34

Show last authors
1 You can use the URL query parameters to add environment variables to a jupyter notebook.
2
3 For example, here is a link to a notebook:
4
5 https:~/~/lab.ebrains.eu/user-redirect/lab/tree/shared/example_path/notebook.ipynb
6
7 To add environment variables that are accessible within that notebook (in this case LAB_MY_VARIABLE) use this URL:
8
9 https:~/~/lab.ebrains.eu/user-redirect/lab/tree/shared/example_path/notebook.ipynb**?LAB_MY_VARIABLE=Hello**
10
11 You can add as many variables as you want but the query string needs to be properly formatted. You can find more info about the query string format [[here>>https://en.wikipedia.org/wiki/Query_string]].
12
13 //Note**:** For the query parameters to be accessible in the notebook they needs to be prefixed with LAB_ e.g. ?LAB_MY_VARIABLE=4 //
14
15 To access a environment variable in the notebook you can use this snipped:
16
17 {{code}}
18 import os
19 os.environ.get('LAB_MY_VARIABLE')
20 {{/code}}
21
22