Skip to content

Commit

Permalink
check if in colab and as y/n before installing
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed Sep 1, 2023
1 parent e116165 commit 1a6d5ac
Show file tree
Hide file tree
Showing 23 changed files with 209 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
"source": [
"import subprocess\n",
"import sys\n",
"\n",
"COLAB = \"google.colab\" in sys.modules\n",
"\n",
"def _install(package):\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
"\n",
" if COLAB:\n",
" ans = input(f\"Install { package }? [y/n]:\")\n",
" if ans.lower() in [\"y\", \"yes\"]:\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
" print(f\"{ package } installed!\")\n",
"\n",
"def _colab_install_missing_deps(deps):\n",
" import importlib\n",
"\n",
" for dep in deps:\n",
" if importlib.util.find_spec(dep) is None:\n",
" if dep == \"iris\":\n",
" dep = \"scitools-iris\"\n",
" _install(dep)\n",
"\n",
"\n",
"deps = [\"erddapy\"]\n",
"deps = ['erddapy']\n",
"_colab_install_missing_deps(deps)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
"source": [
"import subprocess\n",
"import sys\n",
"\n",
"COLAB = \"google.colab\" in sys.modules\n",
"\n",
"def _install(package):\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
"\n",
" if COLAB:\n",
" ans = input(f\"Install { package }? [y/n]:\")\n",
" if ans.lower() in [\"y\", \"yes\"]:\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
" print(f\"{ package } installed!\")\n",
"\n",
"def _colab_install_missing_deps(deps):\n",
" import importlib\n",
"\n",
" for dep in deps:\n",
" if importlib.util.find_spec(dep) is None:\n",
" if dep == \"iris\":\n",
" dep = \"scitools-iris\"\n",
" _install(dep)\n",
"\n",
"\n",
"deps = [\"cf_xarray\", \"palettable\", \"seawater\"]\n",
"deps = ['cf_xarray', 'palettable', 'seawater']\n",
"_colab_install_missing_deps(deps)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
"source": [
"import subprocess\n",
"import sys\n",
"\n",
"COLAB = \"google.colab\" in sys.modules\n",
"\n",
"def _install(package):\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
"\n",
" if COLAB:\n",
" ans = input(f\"Install { package }? [y/n]:\")\n",
" if ans.lower() in [\"y\", \"yes\"]:\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
" print(f\"{ package } installed!\")\n",
"\n",
"def _colab_install_missing_deps(deps):\n",
" import importlib\n",
"\n",
" for dep in deps:\n",
" if importlib.util.find_spec(dep) is None:\n",
" if dep == \"iris\":\n",
" dep = \"scitools-iris\"\n",
" _install(dep)\n",
"\n",
"\n",
"deps = [\"iris\", \"seawater\"]\n",
"deps = ['iris', 'seawater']\n",
"_colab_install_missing_deps(deps)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
"source": [
"import subprocess\n",
"import sys\n",
"\n",
"COLAB = \"google.colab\" in sys.modules\n",
"\n",
"def _install(package):\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
"\n",
" if COLAB:\n",
" ans = input(f\"Install { package }? [y/n]:\")\n",
" if ans.lower() in [\"y\", \"yes\"]:\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
" print(f\"{ package } installed!\")\n",
"\n",
"def _colab_install_missing_deps(deps):\n",
" import importlib\n",
"\n",
" for dep in deps:\n",
" if importlib.util.find_spec(dep) is None:\n",
" if dep == \"iris\":\n",
" dep = \"scitools-iris\"\n",
" _install(dep)\n",
"\n",
"\n",
"deps = [\"erddapy\"]\n",
"deps = ['erddapy']\n",
"_colab_install_missing_deps(deps)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
"source": [
"import subprocess\n",
"import sys\n",
"\n",
"COLAB = \"google.colab\" in sys.modules\n",
"\n",
"def _install(package):\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
"\n",
" if COLAB:\n",
" ans = input(f\"Install { package }? [y/n]:\")\n",
" if ans.lower() in [\"y\", \"yes\"]:\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
" print(f\"{ package } installed!\")\n",
"\n",
"def _colab_install_missing_deps(deps):\n",
" import importlib\n",
"\n",
" for dep in deps:\n",
" if importlib.util.find_spec(dep) is None:\n",
" if dep == \"iris\":\n",
" dep = \"scitools-iris\"\n",
" _install(dep)\n",
"\n",
"\n",
"deps = [\"owslib\"]\n",
"deps = ['owslib']\n",
"_colab_install_missing_deps(deps)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
"source": [
"import subprocess\n",
"import sys\n",
"\n",
"COLAB = \"google.colab\" in sys.modules\n",
"\n",
"def _install(package):\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
"\n",
" if COLAB:\n",
" ans = input(f\"Install { package }? [y/n]:\")\n",
" if ans.lower() in [\"y\", \"yes\"]:\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
" print(f\"{ package } installed!\")\n",
"\n",
"def _colab_install_missing_deps(deps):\n",
" import importlib\n",
"\n",
" for dep in deps:\n",
" if importlib.util.find_spec(dep) is None:\n",
" if dep == \"iris\":\n",
" dep = \"scitools-iris\"\n",
" _install(dep)\n",
"\n",
"\n",
"deps = [\"cf-units\", \"ioos-tools\", \"pyoos\", \"retrying\"]\n",
"deps = ['cf-units', 'ioos-tools', 'pyoos', 'retrying']\n",
"_colab_install_missing_deps(deps)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
"source": [
"import subprocess\n",
"import sys\n",
"\n",
"COLAB = \"google.colab\" in sys.modules\n",
"\n",
"def _install(package):\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
"\n",
" if COLAB:\n",
" ans = input(f\"Install { package }? [y/n]:\")\n",
" if ans.lower() in [\"y\", \"yes\"]:\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
" print(f\"{ package } installed!\")\n",
"\n",
"def _colab_install_missing_deps(deps):\n",
" import importlib\n",
"\n",
" for dep in deps:\n",
" if importlib.util.find_spec(dep) is None:\n",
" if dep == \"iris\":\n",
" dep = \"scitools-iris\"\n",
" _install(dep)\n",
"\n",
"\n",
"deps = [\"cartopy\"]\n",
"deps = ['cartopy']\n",
"_colab_install_missing_deps(deps)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
"source": [
"import subprocess\n",
"import sys\n",
"\n",
"COLAB = \"google.colab\" in sys.modules\n",
"\n",
"def _install(package):\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
"\n",
" if COLAB:\n",
" ans = input(f\"Install { package }? [y/n]:\")\n",
" if ans.lower() in [\"y\", \"yes\"]:\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
" print(f\"{ package } installed!\")\n",
"\n",
"def _colab_install_missing_deps(deps):\n",
" import importlib\n",
"\n",
" for dep in deps:\n",
" if importlib.util.find_spec(dep) is None:\n",
" if dep == \"iris\":\n",
" dep = \"scitools-iris\"\n",
" _install(dep)\n",
"\n",
"\n",
"deps = [\"palettable\"]\n",
"deps = ['palettable']\n",
"_colab_install_missing_deps(deps)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
"source": [
"import subprocess\n",
"import sys\n",
"\n",
"COLAB = \"google.colab\" in sys.modules\n",
"\n",
"def _install(package):\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
"\n",
" if COLAB:\n",
" ans = input(f\"Install { package }? [y/n]:\")\n",
" if ans.lower() in [\"y\", \"yes\"]:\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
" print(f\"{ package } installed!\")\n",
"\n",
"def _colab_install_missing_deps(deps):\n",
" import importlib\n",
"\n",
" for dep in deps:\n",
" if importlib.util.find_spec(dep) is None:\n",
" if dep == \"iris\":\n",
" dep = \"scitools-iris\"\n",
" _install(dep)\n",
"\n",
"\n",
"deps = [\"erddapy\", \"palettable\"]\n",
"deps = ['erddapy', 'palettable']\n",
"_colab_install_missing_deps(deps)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
"source": [
"import subprocess\n",
"import sys\n",
"\n",
"COLAB = \"google.colab\" in sys.modules\n",
"\n",
"def _install(package):\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
"\n",
" if COLAB:\n",
" ans = input(f\"Install { package }? [y/n]:\")\n",
" if ans.lower() in [\"y\", \"yes\"]:\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
" print(f\"{ package } installed!\")\n",
"\n",
"def _colab_install_missing_deps(deps):\n",
" import importlib\n",
"\n",
" for dep in deps:\n",
" if importlib.util.find_spec(dep) is None:\n",
" if dep == \"iris\":\n",
" dep = \"scitools-iris\"\n",
" _install(dep)\n",
"\n",
"\n",
"deps = [\"cartopy\", \"gridgeo\", \"netcdf4\", \"palettable\"]\n",
"deps = ['cartopy', 'gridgeo', 'netcdf4', 'palettable']\n",
"_colab_install_missing_deps(deps)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
"source": [
"import subprocess\n",
"import sys\n",
"\n",
"COLAB = \"google.colab\" in sys.modules\n",
"\n",
"def _install(package):\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
"\n",
" if COLAB:\n",
" ans = input(f\"Install { package }? [y/n]:\")\n",
" if ans.lower() in [\"y\", \"yes\"]:\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
" print(f\"{ package } installed!\")\n",
"\n",
"def _colab_install_missing_deps(deps):\n",
" import importlib\n",
"\n",
" for dep in deps:\n",
" if importlib.util.find_spec(dep) is None:\n",
" if dep == \"iris\":\n",
" dep = \"scitools-iris\"\n",
" _install(dep)\n",
"\n",
"\n",
"deps = [\"cf-units\", \"ioos-tools\", \"pyoos\", \"retrying\"]\n",
"deps = ['cf-units', 'ioos-tools', 'pyoos', 'retrying']\n",
"_colab_install_missing_deps(deps)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
"source": [
"import subprocess\n",
"import sys\n",
"\n",
"COLAB = \"google.colab\" in sys.modules\n",
"\n",
"def _install(package):\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
"\n",
" if COLAB:\n",
" ans = input(f\"Install { package }? [y/n]:\")\n",
" if ans.lower() in [\"y\", \"yes\"]:\n",
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package])\n",
" print(f\"{ package } installed!\")\n",
"\n",
"def _colab_install_missing_deps(deps):\n",
" import importlib\n",
"\n",
" for dep in deps:\n",
" if importlib.util.find_spec(dep) is None:\n",
" if dep == \"iris\":\n",
" dep = \"scitools-iris\"\n",
" _install(dep)\n",
"\n",
"\n",
"deps = [\"ipyleaflet\"]\n",
"deps = ['ipyleaflet']\n",
"_colab_install_missing_deps(deps)"
]
},
Expand Down
Loading

0 comments on commit 1a6d5ac

Please sign in to comment.