Skip to content

Commit 0da2d29

Browse files
committed
🎨 Style(vuegen_case_study_earth_microbiome.ipynb): Update EMP example notebook with boolean for colab
1 parent 630cb90 commit 0da2d29

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

‎docs/vuegen_case_study_earth_microbiome.ipynb‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"source": [
6262
"### 0.1. Installing libraries and creating global variables for platform and working directory\n",
6363
"\n",
64-
"To run this notebook locally, you should create a virtual environment with the required libraries and set the `platform` variable to `local_notebook`. If you are running this notebook on Google Colab, set the `platform` variable to `colab`."
64+
"To run this notebook locally, you should create a virtual environment with the required libraries. If you are running this notebook on Google Colab, everything should be set."
6565
]
6666
},
6767
{
@@ -90,7 +90,8 @@
9090
"metadata": {},
9191
"outputs": [],
9292
"source": [
93-
"platform = 'local_notebook' #@param ['colab', 'local_notebook'] {allow-input: true}"
93+
"import os\n",
94+
"IN_COLAB = \"COLAB_GPU\" in os.environ"
9495
]
9596
},
9697
{
@@ -100,7 +101,7 @@
100101
"outputs": [],
101102
"source": [
102103
"# Optional library to launch a streamlit app from colab\n",
103-
"if platform == 'colab':\n",
104+
"if IN_COLAB:\n",
104105
" !npm install localtunnel"
105106
]
106107
},
@@ -148,7 +149,7 @@
148149
"from vuegen import report_generator\n",
149150
"from vuegen.utils import get_logger, load_yaml_config\n",
150151
"\n",
151-
"if platform == 'colab':\n",
152+
"if IN_COLAB:\n",
152153
" import urllib"
153154
]
154155
},
@@ -1388,10 +1389,10 @@
13881389
"metadata": {},
13891390
"outputs": [],
13901391
"source": [
1391-
"# Launch the Streamlit report depneding on the platform\n",
1392-
"#if platform == \"local_notebook\":\n",
1392+
"# # Launch the Streamlit report depneding on the platform\n",
1393+
"# if not IN_COLAB:\n",
13931394
"# !streamlit run streamlit_report/sections/report_manager.py\n",
1394-
"#elif platform == \"colab\": # https://discuss.streamlit.io/t/how-to-launch-streamlit-app-from-google-colab-notebook/42399\n",
1395+
"# else: # https://discuss.streamlit.io/t/how-to-launch-streamlit-app-from-google-colab-notebook/42399\n",
13951396
"# print(\"Password/Enpoint IP for localtunnel is:\",urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n",
13961397
"# !streamlit run streamlit_report/sections/report_manager.py --server.address=localhost &>/content/logs.txt &\n",
13971398
"# !npx localtunnel --port 8501"
@@ -1567,10 +1568,10 @@
15671568
"metadata": {},
15681569
"outputs": [],
15691570
"source": [
1570-
"# Launch the Streamlit report depneding on the platform\n",
1571-
"#if platform == \"local_notebook\":\n",
1571+
"# # Launch the Streamlit report depneding on the platform\n",
1572+
"# if not IN_COLAB:\n",
15721573
"# !streamlit run streamlit_report/sections/report_manager.py\n",
1573-
"#elif platform == \"colab\":\n",
1574+
"# else: # https://discuss.streamlit.io/t/how-to-launch-streamlit-app-from-google-colab-notebook/42399\n",
15741575
"# print(\"Password/Enpoint IP for localtunnel is:\",urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n",
15751576
"# !streamlit run streamlit_report/sections/report_manager.py --server.address=localhost &>/content/logs.txt &\n",
15761577
"# !npx localtunnel --port 8501"

0 commit comments

Comments
 (0)