File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 2323 "outputs" : [],
2424 "source" : [
2525 " # Setup to enable running the notebook in the Google Colab environment\n " ,
26- " import os \n " ,
26+ " import pathlib \n " ,
2727 " \n " ,
28- " if \" COLAB_NOTEBOOK_ID\" in os.environ:\n " ,
29- " !git clone https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks\n " ,
28+ " def _in_colab() -> bool:\n " ,
29+ " try:\n " ,
30+ " import google.colab # noqa: F401\n " ,
31+ " return True\n " ,
32+ " except Exception:\n " ,
33+ " return False\n " ,
34+ " \n " ,
35+ " if _in_colab():\n " ,
36+ " repo_dir = pathlib.Path(\" SimpleITK-Notebooks\" )\n " ,
37+ " if not repo_dir.exists():\n " ,
38+ " !git clone --depth 1 https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks\n " ,
3039 " %cd SimpleITK-Notebooks/Python\n " ,
31- " !pip install -q -r requirements.txt"
40+ " !pip install -q -r requirements.txt\n "
3241 ]
3342 },
3443 {
You can’t perform that action at this time.
0 commit comments