Skip to content

Commit 23e74d9

Browse files
committed
🎨 add boolean for colab
1 parent 8aa3908 commit 23e74d9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

docs/vuegen_basic_case_study.ipynb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@
5454
"source": [
5555
"### 0.1. Installing libraries and creating global variables for platform and working directory\n",
5656
"\n",
57-
"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`."
57+
"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."
5858
]
5959
},
6060
{
6161
"cell_type": "code",
6262
"execution_count": null,
63-
"metadata": {},
63+
"metadata": {
64+
"tags": [
65+
"hide-output"
66+
]
67+
},
6468
"outputs": [],
6569
"source": [
6670
"# Vuegen library \n",
@@ -73,7 +77,7 @@
7377
"metadata": {},
7478
"outputs": [],
7579
"source": [
76-
"platform = 'local_notebook' #@param ['colab', 'local_notebook'] {allow-input: true}"
80+
"IN_COLAB = \"COLAB_GPU\" in os.environ"
7781
]
7882
},
7983
{
@@ -83,11 +87,11 @@
8387
"outputs": [],
8488
"source": [
8589
"# Set working directory\n",
86-
"if platform == 'colab':\n",
90+
"if IN_COLAB:\n",
8791
" # Clone the repository in Colab\n",
8892
" !git clone --depth=1 https://github.com/Multiomics-Analytics-Group/vuegen.git\n",
8993
" base_output_dir = \"vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/\"\n",
90-
"elif platform == 'local_notebook':\n",
94+
"else:\n",
9195
" # Output directory for local execution\n",
9296
" base_output_dir = \"./example_data/Basic_example_vuegen_demo_notebook/\""
9397
]
@@ -99,7 +103,7 @@
99103
"outputs": [],
100104
"source": [
101105
"# Optional library to launch a streamlit app from colab\n",
102-
"if platform == 'colab':\n",
106+
"if IN_COLAB:\n",
103107
" !npm install localtunnel"
104108
]
105109
},
@@ -112,7 +116,7 @@
112116
},
113117
{
114118
"cell_type": "code",
115-
"execution_count": 27,
119+
"execution_count": null,
116120
"metadata": {},
117121
"outputs": [],
118122
"source": [
@@ -122,7 +126,7 @@
122126
"from vuegen import report_generator\n",
123127
"from vuegen.utils import get_logger, load_yaml_config\n",
124128
"\n",
125-
"if platform == 'colab':\n",
129+
"if IN_COLAB:\n",
126130
" import urllib"
127131
]
128132
},
@@ -310,7 +314,7 @@
310314
"outputs": [],
311315
"source": [
312316
"# Launch the Streamlit report depneding on the platform\n",
313-
"#if platform == \"local_notebook\":\n",
317+
"#if not IN_COLAB:\n",
314318
"# !streamlit run streamlit_report/sections/report_manager.py\n",
315319
"#elif platform == \"colab\":\n",
316320
"# print(\"Password/Enpoint IP for localtunnel is:\",urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n",

0 commit comments

Comments
 (0)