Skip to content

Commit bb86266

Browse files
authored
Merge pull request #498 from Masood-Akram/fix/notebook-fix
colab: make setup cell more robust
2 parents f4a4163 + 52a2fcd commit bb86266

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Python/01_Image_Basics.ipynb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@
2323
"outputs": [],
2424
"source": [
2525
"# Setup to enable running the notebook in the Google Colab environment\n",
26-
"import os\n",
2726
"\n",
28-
"if \"COLAB_NOTEBOOK_ID\" in os.environ:\n",
29-
" !git clone https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks\n",
27+
"try:\n",
28+
" import google.colab\n",
29+
" import pathlib\n",
30+
"\n",
31+
" repo_dir = pathlib.Path(\"SimpleITK-Notebooks\")\n",
32+
" if not repo_dir.exists():\n",
33+
" !git clone --depth 1 https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks\n",
3034
" %cd SimpleITK-Notebooks/Python\n",
31-
" !pip install -q -r requirements.txt"
35+
" !pip install -q -r requirements.txt\n",
36+
"\n",
37+
"except ImportError:\n",
38+
" pass # not on Colab"
3239
]
3340
},
3441
{

Python/36_Microscopy_Colocalization_Distance_Analysis.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"import numpy as np\n",
2626
"import pandas as pd\n",
2727
"\n",
28-
"\n",
2928
"%matplotlib widget\n",
3029
"import gui\n",
3130
"\n",

Python/71_Trust_But_Verify.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
"import matplotlib.pyplot as plt\n",
7676
"import ipywidgets as widgets\n",
7777
"\n",
78-
"\n",
7978
"# utility method that either downloads data from the Girder repository or\n",
8079
"# if already downloaded returns the file name for reading from disk (cached data)\n",
8180
"%run update_path_to_download_script\n",

0 commit comments

Comments
 (0)