From 1a6d5aceabcef1cbe0ada694b95cc2d83c0d8e27 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Fri, 1 Sep 2023 14:44:01 -0300 Subject: [PATCH] check if in colab and as y/n before installing --- .../2016-10-12-fetching_data.ipynb | 15 +++++++++------ .../2016-11-15-glider_data_example.ipynb | 15 +++++++++------ ...016-12-20-searching_glider_deployments.ipynb | 15 +++++++++------ .../2017-03-21-ERDDAP_IOOS_Sensor_Map.ipynb | 15 +++++++++------ .../2017-06-12-NCEI_RA_archive_history.ipynb | 15 +++++++++------ .../2017-09-09-hurricane_irma.ipynb | 15 +++++++++------ .../2017-11-30-rerddap.ipynb | 15 +++++++++------ .../data_access_notebooks/2018-02-20-obis.ipynb | 15 +++++++++------ .../2018-03-01-erddapy.ipynb | 15 +++++++++------ .../2019-03-08-grids-temperature.ipynb | 15 +++++++++------ .../2019-05-27-hurricane_gis_part02.ipynb | 15 +++++++++------ .../data_access_notebooks/2020-10-10-GTS.ipynb | 15 +++++++++------ .../2021-10-19-multiple-erddap-search.ipynb | 15 +++++++++------ .../2022-11-23_pyobis_example.ipynb | 15 +++++++++------ .../2016-11-16-CF-UGRID-SGRID-conventions.ipynb | 15 +++++++++------ .../2018-12-04-grids.ipynb | 15 +++++++++------ ...-14-QARTOD_ioos_qc_Water-Level-Example.ipynb | 15 +++++++++------ .../2021-10-25-ERDDAP-interpolate.ipynb | 17 ++++++++++------- .../2017-05-14-running_compliance_checker.ipynb | 15 +++++++++------ ...17-11-01-Creating-Archives-Using-Bagit.ipynb | 15 +++++++++------ .../2018-02-27-pocean-timeSeries-demo.ipynb | 15 +++++++++------ .../2020-12-08-DataToDwC.ipynb | 15 +++++++++------ .../2023-03-20-Reading_and_writing_zarr.ipynb | 17 ++++++++++------- 23 files changed, 209 insertions(+), 140 deletions(-) diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2016-10-12-fetching_data.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2016-10-12-fetching_data.ipynb index 5d241a9c..38928d51 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2016-10-12-fetching_data.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2016-10-12-fetching_data.ipynb @@ -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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2016-11-15-glider_data_example.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2016-11-15-glider_data_example.ipynb index eb370232..d3dc2986 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2016-11-15-glider_data_example.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2016-11-15-glider_data_example.ipynb @@ -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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2016-12-20-searching_glider_deployments.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2016-12-20-searching_glider_deployments.ipynb index 72f6b236..ab7c0150 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2016-12-20-searching_glider_deployments.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2016-12-20-searching_glider_deployments.ipynb @@ -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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2017-03-21-ERDDAP_IOOS_Sensor_Map.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2017-03-21-ERDDAP_IOOS_Sensor_Map.ipynb index affdbb38..800806ff 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2017-03-21-ERDDAP_IOOS_Sensor_Map.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2017-03-21-ERDDAP_IOOS_Sensor_Map.ipynb @@ -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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2017-06-12-NCEI_RA_archive_history.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2017-06-12-NCEI_RA_archive_history.ipynb index f4e9ae8e..5267fb9b 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2017-06-12-NCEI_RA_archive_history.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2017-06-12-NCEI_RA_archive_history.ipynb @@ -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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2017-09-09-hurricane_irma.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2017-09-09-hurricane_irma.ipynb index 4a6e7dc0..1ee04c21 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2017-09-09-hurricane_irma.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2017-09-09-hurricane_irma.ipynb @@ -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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2017-11-30-rerddap.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2017-11-30-rerddap.ipynb index 214e59b0..0a6f3b9b 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2017-11-30-rerddap.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2017-11-30-rerddap.ipynb @@ -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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2018-02-20-obis.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2018-02-20-obis.ipynb index 9af2912d..bebe75a7 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2018-02-20-obis.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2018-02-20-obis.ipynb @@ -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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2018-03-01-erddapy.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2018-03-01-erddapy.ipynb index 11ef55a1..72ef91ca 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2018-03-01-erddapy.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2018-03-01-erddapy.ipynb @@ -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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2019-03-08-grids-temperature.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2019-03-08-grids-temperature.ipynb index 450a6458..91fbd299 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2019-03-08-grids-temperature.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2019-03-08-grids-temperature.ipynb @@ -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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2019-05-27-hurricane_gis_part02.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2019-05-27-hurricane_gis_part02.ipynb index aa0dedd2..00fbc442 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2019-05-27-hurricane_gis_part02.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2019-05-27-hurricane_gis_part02.ipynb @@ -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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2020-10-10-GTS.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2020-10-10-GTS.ipynb index 12cb116a..c1ea8d67 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2020-10-10-GTS.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2020-10-10-GTS.ipynb @@ -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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2021-10-19-multiple-erddap-search.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2021-10-19-multiple-erddap-search.ipynb index c1c75920..01bc22eb 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2021-10-19-multiple-erddap-search.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2021-10-19-multiple-erddap-search.ipynb @@ -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\", \"ipyleaflet\", \"seawater\"]\n", + "deps = ['erddapy', 'ipyleaflet', 'seawater']\n", "_colab_install_missing_deps(deps)" ] }, diff --git a/jupyterbook/content/code_gallery/data_access_notebooks/2022-11-23_pyobis_example.ipynb b/jupyterbook/content/code_gallery/data_access_notebooks/2022-11-23_pyobis_example.ipynb index da2c3a0a..e3fd70a6 100644 --- a/jupyterbook/content/code_gallery/data_access_notebooks/2022-11-23_pyobis_example.ipynb +++ b/jupyterbook/content/code_gallery/data_access_notebooks/2022-11-23_pyobis_example.ipynb @@ -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 = [\"geoplot\", \"pyobis\"]\n", + "deps = ['geoplot', 'pyobis']\n", "_colab_install_missing_deps(deps)" ] }, diff --git a/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2016-11-16-CF-UGRID-SGRID-conventions.ipynb b/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2016-11-16-CF-UGRID-SGRID-conventions.ipynb index 3e2f6918..c305e1a3 100644 --- a/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2016-11-16-CF-UGRID-SGRID-conventions.ipynb +++ b/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2016-11-16-CF-UGRID-SGRID-conventions.ipynb @@ -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\", \"cf_xarray\", \"netcdf4\", \"odvc\", \"pysgrid\", \"pyugrid\"]\n", + "deps = ['cartopy', 'cf_xarray', 'netcdf4', 'odvc', 'pysgrid', 'pyugrid']\n", "_colab_install_missing_deps(deps)" ] }, diff --git a/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2018-12-04-grids.ipynb b/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2018-12-04-grids.ipynb index 4f8275fe..5010aa2e 100644 --- a/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2018-12-04-grids.ipynb +++ b/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2018-12-04-grids.ipynb @@ -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\"]\n", + "deps = ['cartopy', 'gridgeo', 'netcdf4']\n", "_colab_install_missing_deps(deps)" ] }, diff --git a/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2020-02-14-QARTOD_ioos_qc_Water-Level-Example.ipynb b/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2020-02-14-QARTOD_ioos_qc_Water-Level-Example.ipynb index df76a433..cd1c1d47 100644 --- a/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2020-02-14-QARTOD_ioos_qc_Water-Level-Example.ipynb +++ b/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2020-02-14-QARTOD_ioos_qc_Water-Level-Example.ipynb @@ -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\", \"erddapy\", \"ioos_qc\"]\n", + "deps = ['cf_xarray', 'erddapy', 'ioos_qc']\n", "_colab_install_missing_deps(deps)" ] }, diff --git a/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2021-10-25-ERDDAP-interpolate.ipynb b/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2021-10-25-ERDDAP-interpolate.ipynb index e197c012..e1c8df51 100644 --- a/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2021-10-25-ERDDAP-interpolate.ipynb +++ b/jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/2021-10-25-ERDDAP-interpolate.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a520a48d", + "id": "2637369a", "metadata": { "tags": [ "remove-cell" @@ -13,21 +13,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)" ] }, diff --git a/jupyterbook/content/code_gallery/data_management_notebooks/2017-05-14-running_compliance_checker.ipynb b/jupyterbook/content/code_gallery/data_management_notebooks/2017-05-14-running_compliance_checker.ipynb index c712d90e..8591c0c8 100644 --- a/jupyterbook/content/code_gallery/data_management_notebooks/2017-05-14-running_compliance_checker.ipynb +++ b/jupyterbook/content/code_gallery/data_management_notebooks/2017-05-14-running_compliance_checker.ipynb @@ -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 = [\"compliance-checker\"]\n", + "deps = ['compliance-checker']\n", "_colab_install_missing_deps(deps)" ] }, diff --git a/jupyterbook/content/code_gallery/data_management_notebooks/2017-11-01-Creating-Archives-Using-Bagit.ipynb b/jupyterbook/content/code_gallery/data_management_notebooks/2017-11-01-Creating-Archives-Using-Bagit.ipynb index f161233c..89c64f51 100644 --- a/jupyterbook/content/code_gallery/data_management_notebooks/2017-11-01-Creating-Archives-Using-Bagit.ipynb +++ b/jupyterbook/content/code_gallery/data_management_notebooks/2017-11-01-Creating-Archives-Using-Bagit.ipynb @@ -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 = [\"bagit\", \"pocean-core\"]\n", + "deps = ['bagit', 'pocean-core']\n", "_colab_install_missing_deps(deps)" ] }, diff --git a/jupyterbook/content/code_gallery/data_management_notebooks/2018-02-27-pocean-timeSeries-demo.ipynb b/jupyterbook/content/code_gallery/data_management_notebooks/2018-02-27-pocean-timeSeries-demo.ipynb index b9e81d30..f74e9513 100644 --- a/jupyterbook/content/code_gallery/data_management_notebooks/2018-02-27-pocean-timeSeries-demo.ipynb +++ b/jupyterbook/content/code_gallery/data_management_notebooks/2018-02-27-pocean-timeSeries-demo.ipynb @@ -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 = [\"oceans\", \"pocean-core\"]\n", + "deps = ['oceans', 'pocean-core']\n", "_colab_install_missing_deps(deps)" ] }, diff --git a/jupyterbook/content/code_gallery/data_management_notebooks/2020-12-08-DataToDwC.ipynb b/jupyterbook/content/code_gallery/data_management_notebooks/2020-12-08-DataToDwC.ipynb index 82158bf0..9140ec47 100644 --- a/jupyterbook/content/code_gallery/data_management_notebooks/2020-12-08-DataToDwC.ipynb +++ b/jupyterbook/content/code_gallery/data_management_notebooks/2020-12-08-DataToDwC.ipynb @@ -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 = [\"pyworms\"]\n", + "deps = ['pyworms']\n", "_colab_install_missing_deps(deps)" ] }, diff --git a/jupyterbook/content/code_gallery/data_management_notebooks/2023-03-20-Reading_and_writing_zarr.ipynb b/jupyterbook/content/code_gallery/data_management_notebooks/2023-03-20-Reading_and_writing_zarr.ipynb index 58a48d35..05c4537a 100644 --- a/jupyterbook/content/code_gallery/data_management_notebooks/2023-03-20-Reading_and_writing_zarr.ipynb +++ b/jupyterbook/content/code_gallery/data_management_notebooks/2023-03-20-Reading_and_writing_zarr.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e56e87a9", + "id": "04d735b6", "metadata": { "tags": [ "remove-cell" @@ -13,21 +13,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 = [\"zarr\"]\n", + "deps = ['zarr']\n", "_colab_install_missing_deps(deps)" ] },