diff --git a/docs/index.md b/docs/index.md index 4e8f239..50220d8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,6 +2,7 @@ + ```{include} ../README.md :start-line: 0 :relative-docs: docs @@ -18,6 +19,7 @@ vuegen_demo :maxdepth: 1 :caption: Building a report +vuegen_basic_case_study vuegen_case_study_earth_microbiome example_report ``` diff --git a/docs/vuegen_basic_case_study.ipynb b/docs/vuegen_basic_case_study.ipynb index 34cbd81..1268256 100644 --- a/docs/vuegen_basic_case_study.ipynb +++ b/docs/vuegen_basic_case_study.ipynb @@ -54,13 +54,17 @@ "source": [ "### 0.1. Installing libraries and creating global variables for platform and working directory\n", "\n", - "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`." + "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." ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [ + "hide-output" + ] + }, "outputs": [], "source": [ "# Vuegen library \n", @@ -69,11 +73,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ - "platform = 'local_notebook' #@param ['colab', 'local_notebook'] {allow-input: true}" + "import os\n", + "IN_COLAB = \"COLAB_GPU\" in os.environ" ] }, { @@ -83,11 +88,11 @@ "outputs": [], "source": [ "# Set working directory\n", - "if platform == 'colab':\n", + "if IN_COLAB:\n", " # Clone the repository in Colab\n", " !git clone --depth=1 https://github.com/Multiomics-Analytics-Group/vuegen.git\n", " base_output_dir = \"vuegen/docs/example_data/Basic_example_vuegen_demo_notebook/\"\n", - "elif platform == 'local_notebook':\n", + "else:\n", " # Output directory for local execution\n", " base_output_dir = \"./example_data/Basic_example_vuegen_demo_notebook/\"" ] @@ -99,7 +104,7 @@ "outputs": [], "source": [ "# Optional library to launch a streamlit app from colab\n", - "if platform == 'colab':\n", + "if IN_COLAB:\n", " !npm install localtunnel" ] }, @@ -112,7 +117,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -122,7 +127,7 @@ "from vuegen import report_generator\n", "from vuegen.utils import get_logger, load_yaml_config\n", "\n", - "if platform == 'colab':\n", + "if IN_COLAB:\n", " import urllib" ] }, @@ -146,7 +151,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 1.1. Streamlit report" + "### 1.1. Streamlit report\n", + "\n", + "To launch the Streamlit web application from Colab, open the generated URL and copy the localtunnel entry point IP into the corresponding field on the opened page. Once submited, you will be redirected to your Streamlit web application." ] }, { @@ -164,15 +171,30 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Streamlit report not executed, set run_streamlit to True to run the report\n" + ] + } + ], "source": [ + "run_streamlit = False\n", + "# run_streamlit = True # uncomment line to run the streamlit report\n", "# Launch the Streamlit report depneding on the platform\n", - "# if platform == \"local_notebook\":\n", - "# !streamlit run streamlit_report/sections/report_manager.py\n", - "# elif platform == \"colab\": # https://discuss.streamlit.io/t/how-to-launch-streamlit-app-from-google-colab-notebook/42399\n", - "# print(\"Password/Enpoint IP for localtunnel is:\",urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n", - "# !streamlit run streamlit_report/sections/report_manager.py --server.address=localhost &>/content/logs.txt &\n", - "# !npx localtunnel --port 8501" + "if not IN_COLAB and run_streamlit:\n", + " !streamlit run streamlit_report/sections/report_manager.py\n", + "elif run_streamlit:\n", + " # see: https://discuss.streamlit.io/t/how-to-launch-streamlit-app-from-google-colab-notebook/42399\n", + " print(\"Password/Enpoint IP for localtunnel is:\",urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n", + " # Run the Streamlit app in the background\n", + " !streamlit run streamlit_report/sections/report_manager.py --server.address=localhost &>/content/logs.txt &\n", + " # Expose the Streamlit app on port 8501\n", + " !npx localtunnel --port 8501 --subdomain vuegen-demo\n", + "else:\n", + " print(\"Streamlit report not executed, set run_streamlit to True to run the report\")" ] }, { @@ -289,7 +311,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 2.5. Stremlit report with the extended configuration file" + "### 2.5. Stremlit report with the extended configuration file\n", + "\n", + "To launch the Streamlit web application from Colab, open the generated URL and copy the localtunnel entry point IP into the corresponding field on the opened page. Once submited, you will be redirected to your Streamlit web application." ] }, { @@ -309,13 +333,20 @@ "metadata": {}, "outputs": [], "source": [ + "run_streamlit = False\n", + "# run_streamlit = True # uncomment line to run the streamlit report\n", "# Launch the Streamlit report depneding on the platform\n", - "#if platform == \"local_notebook\":\n", - "# !streamlit run streamlit_report/sections/report_manager.py\n", - "#elif platform == \"colab\":\n", - "# print(\"Password/Enpoint IP for localtunnel is:\",urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n", - "# !streamlit run streamlit_report/sections/report_manager.py --server.address=localhost &>/content/logs.txt &\n", - "# !npx localtunnel --port 8501" + "if not IN_COLAB and run_streamlit:\n", + " !streamlit run streamlit_report/sections/report_manager.py\n", + "elif run_streamlit:\n", + " # see: https://discuss.streamlit.io/t/how-to-launch-streamlit-app-from-google-colab-notebook/42399\n", + " print(\"Password/Enpoint IP for localtunnel is:\",urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n", + " # Run the Streamlit app in the background\n", + " !streamlit run streamlit_report/sections/report_manager.py --server.address=localhost &>/content/logs.txt &\n", + " # Expose the Streamlit app on port 8501\n", + " !npx localtunnel --port 8501 --subdomain vuegen-demo\n", + "else:\n", + " print(\"Streamlit report not executed, set run_streamlit to True to run the report\")" ] }, { @@ -339,7 +370,7 @@ ], "metadata": { "kernelspec": { - "display_name": "vuegen-IFxaxej_-py3.12", + "display_name": "vuegen", "language": "python", "name": "python3" }, @@ -353,7 +384,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.6" + "version": "3.9.21" } }, "nbformat": 4, diff --git a/docs/vuegen_case_study_earth_microbiome.ipynb b/docs/vuegen_case_study_earth_microbiome.ipynb index 5e1f0ea..1dff5eb 100644 --- a/docs/vuegen_case_study_earth_microbiome.ipynb +++ b/docs/vuegen_case_study_earth_microbiome.ipynb @@ -61,7 +61,7 @@ "source": [ "### 0.1. Installing libraries and creating global variables for platform and working directory\n", "\n", - "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`." + "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." ] }, { @@ -90,7 +90,8 @@ "metadata": {}, "outputs": [], "source": [ - "platform = 'local_notebook' #@param ['colab', 'local_notebook'] {allow-input: true}" + "import os\n", + "IN_COLAB = \"COLAB_GPU\" in os.environ" ] }, { @@ -100,7 +101,7 @@ "outputs": [], "source": [ "# Optional library to launch a streamlit app from colab\n", - "if platform == 'colab':\n", + "if IN_COLAB:\n", " !npm install localtunnel" ] }, @@ -148,7 +149,7 @@ "from vuegen import report_generator\n", "from vuegen.utils import get_logger, load_yaml_config\n", "\n", - "if platform == 'colab':\n", + "if IN_COLAB:\n", " import urllib" ] }, @@ -1368,7 +1369,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 4.1. Streamlit report" + "### 4.1. Streamlit report\n", + "\n", + "To launch the Streamlit web application from Colab, open the generated URL and copy the localtunnel entry point IP into the corresponding field on the opened page. Once submited, you will be redirected to your Streamlit web application." ] }, { @@ -1388,13 +1391,20 @@ "metadata": {}, "outputs": [], "source": [ + "run_streamlit = False\n", + "# run_streamlit = True # uncomment line to run the streamlit report\n", "# Launch the Streamlit report depneding on the platform\n", - "#if platform == \"local_notebook\":\n", - "# !streamlit run streamlit_report/sections/report_manager.py\n", - "#elif platform == \"colab\": # https://discuss.streamlit.io/t/how-to-launch-streamlit-app-from-google-colab-notebook/42399\n", - "# print(\"Password/Enpoint IP for localtunnel is:\",urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n", - "# !streamlit run streamlit_report/sections/report_manager.py --server.address=localhost &>/content/logs.txt &\n", - "# !npx localtunnel --port 8501" + "if not IN_COLAB and run_streamlit:\n", + " !streamlit run streamlit_report/sections/report_manager.py\n", + "elif run_streamlit:\n", + " # see: https://discuss.streamlit.io/t/how-to-launch-streamlit-app-from-google-colab-notebook/42399\n", + " print(\"Password/Enpoint IP for localtunnel is:\",urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n", + " # Run the Streamlit app in the background\n", + " !streamlit run streamlit_report/sections/report_manager.py --server.address=localhost &>/content/logs.txt &\n", + " # Expose the Streamlit app on port 8501\n", + " !npx localtunnel --port 8501 --subdomain vuegen-demo\n", + "else:\n", + " print(\"Streamlit report not executed, set run_streamlit to True to run the report\")" ] }, { @@ -1547,7 +1557,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 5.5. Stremlit report with the extended configuration file" + "### 5.5. Stremlit report with the extended configuration file\n", + "\n", + "To launch the Streamlit web application from Colab, open the generated URL and copy the localtunnel entry point IP into the corresponding field on the opened page. Once submited, you will be redirected to your Streamlit web application." ] }, { @@ -1567,13 +1579,20 @@ "metadata": {}, "outputs": [], "source": [ + "run_streamlit = False\n", + "# run_streamlit = True # uncomment line to run the streamlit report\n", "# Launch the Streamlit report depneding on the platform\n", - "#if platform == \"local_notebook\":\n", - "# !streamlit run streamlit_report/sections/report_manager.py\n", - "#elif platform == \"colab\":\n", - "# print(\"Password/Enpoint IP for localtunnel is:\",urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n", - "# !streamlit run streamlit_report/sections/report_manager.py --server.address=localhost &>/content/logs.txt &\n", - "# !npx localtunnel --port 8501" + "if not IN_COLAB and run_streamlit:\n", + " !streamlit run streamlit_report/sections/report_manager.py\n", + "elif run_streamlit:\n", + " # see: https://discuss.streamlit.io/t/how-to-launch-streamlit-app-from-google-colab-notebook/42399\n", + " print(\"Password/Enpoint IP for localtunnel is:\",urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n", + " # Run the Streamlit app in the background\n", + " !streamlit run streamlit_report/sections/report_manager.py --server.address=localhost &>/content/logs.txt &\n", + " # Expose the Streamlit app on port 8501\n", + " !npx localtunnel --port 8501 --subdomain vuegen-demo\n", + "else:\n", + " print(\"Streamlit report not executed, set run_streamlit to True to run the report\")" ] }, { @@ -1597,7 +1616,7 @@ ], "metadata": { "kernelspec": { - "display_name": "vuegen-IFxaxej_-py3.12", + "display_name": "vuegen", "language": "python", "name": "python3" }, @@ -1611,7 +1630,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.6" + "version": "3.9.21" } }, "nbformat": 4,