Skip to content

Commit

Permalink
HARMONY-1909: Fix make build.
Browse files Browse the repository at this point in the history
  • Loading branch information
ygliuvt committed Oct 11, 2024
1 parent 09f1c1f commit e9c8c07
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 87 deletions.
7 changes: 5 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ build:
sphinx:
configuration: docs/conf.py

# Optionally set the version of Python and requirements required to build your docs
# Install Python dependencies using pyproject.toml
python:
install:
- requirements: requirements/docs.txt
- method: pip
path: .
extra_requirements:
- docs
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ clean-docs:

install:
python -m pip install --upgrade pip
pip install -r requirements/core.txt -r requirements/dev.txt -r requirements/docs.txt
pip install .
pip install .[dev,docs]

install-examples: install
pip install -r requirements/examples.txt
pip install .[examples]

examples: install-examples
jupyter-lab
Expand Down
38 changes: 19 additions & 19 deletions docs/user/notebook.html
Original file line number Diff line number Diff line change
Expand Up @@ -7495,20 +7495,20 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-InputPrompt jp-InputArea-prompt">In [1]:</div>
<div class="jp-CodeMirrorEditor jp-Editor jp-InputArea-editor" data-type="inline">
<div class="cm-editor cm-s-jupyter">
<div class="highlight hl-ipython3"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span><span class="p">;</span> <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">'..'</span><span class="p">)</span>
<span class="o">!{</span>sys.executable<span class="o">}</span><span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>-q<span class="w"> </span>-r<span class="w"> </span>../requirements/examples.txt
<div class="highlight hl-ipython3"><pre><span></span><span class="kn">import</span> <span class="nn">helper</span>

<span class="c1"># Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel</span>
<span class="o">!{</span>sys.executable<span class="o">}</span><span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>-q<span class="w"> </span>-r<span class="w"> </span>../requirements/core.txt
<span class="c1"># Install the project with both 'examples' and 'dev' extra dependencies</span>
<span class="n">helper</span><span class="o">.</span><span class="n">install_project_and_dependencies</span><span class="p">(</span><span class="s1">'..'</span><span class="p">,</span> <span class="n">libs</span><span class="o">=</span><span class="p">[</span><span class="s1">'examples'</span><span class="p">])</span>

<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">datetime</span> <span class="k">as</span> <span class="nn">dt</span>
<span class="kn">from</span> <span class="nn">IPython.display</span> <span class="kn">import</span> <span class="n">display</span><span class="p">,</span> <span class="n">JSON</span>
<span class="kn">import</span> <span class="nn">rasterio</span>
<span class="kn">import</span> <span class="nn">rasterio.plot</span>
<span class="kn">import</span> <span class="nn">netCDF4</span> <span class="k">as</span> <span class="nn">nc4</span>
<span class="kn">from</span> <span class="nn">matplotlib</span> <span class="kn">import</span> <span class="n">pyplot</span> <span class="k">as</span> <span class="n">plt</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">helper</span>


<span class="kn">from</span> <span class="nn">harmony</span> <span class="kn">import</span> <span class="n">BBox</span><span class="p">,</span> <span class="n">WKT</span><span class="p">,</span> <span class="n">Client</span><span class="p">,</span> <span class="n">Collection</span><span class="p">,</span> <span class="n">Request</span><span class="p">,</span> <span class="n">Environment</span>
</pre></div>
Expand Down Expand Up @@ -7719,7 +7719,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child">
<div class="jp-OutputPrompt jp-OutputArea-prompt"></div>
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain" tabindex="0">
<pre>/tmp/4856803_2020_01_01_7f00ff_global_blue_var_regridded_subsetted.tif
<pre>/tmp/4857426_2020_01_01_7f00ff_global_blue_var_regridded_subsetted.tif
</pre>
</div>
</div>
Expand All @@ -7732,7 +7732,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child">
<div class="jp-OutputPrompt jp-OutputArea-prompt"></div>
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain" tabindex="0">
<pre>/tmp/4856804_2020_01_01_7f00ff_global_blue_var_regridded_subsetted.tif
<pre>/tmp/4857427_2020_01_01_7f00ff_global_blue_var_regridded_subsetted.tif
</pre>
</div>
</div>
Expand All @@ -7745,7 +7745,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child">
<div class="jp-OutputPrompt jp-OutputArea-prompt"></div>
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain" tabindex="0">
<pre>/tmp/4856805_2020_01_02_3200ff_global_blue_var_regridded_subsetted.tif
<pre>/tmp/4857428_2020_01_02_3200ff_global_blue_var_regridded_subsetted.tif
</pre>
</div>
</div>
Expand All @@ -7758,7 +7758,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child">
<div class="jp-OutputPrompt jp-OutputArea-prompt"></div>
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain" tabindex="0">
<pre>/tmp/4856806_2020_01_03_0019ff_global_blue_var_regridded_subsetted.tif
<pre>/tmp/4857429_2020_01_03_0019ff_global_blue_var_regridded_subsetted.tif
</pre>
</div>
</div>
Expand All @@ -7771,7 +7771,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child">
<div class="jp-OutputPrompt jp-OutputArea-prompt"></div>
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain" tabindex="0">
<pre>/tmp/4856807_2020_01_04_0065ff_global_blue_var_regridded_subsetted.tif
<pre>/tmp/4857430_2020_01_04_0065ff_global_blue_var_regridded_subsetted.tif
</pre>
</div>
</div>
Expand All @@ -7784,7 +7784,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child">
<div class="jp-OutputPrompt jp-OutputArea-prompt"></div>
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain" tabindex="0">
<pre>/tmp/4856808_2020_01_05_00b2ff_global_blue_var_regridded_subsetted.tif
<pre>/tmp/4857431_2020_01_05_00b2ff_global_blue_var_regridded_subsetted.tif
</pre>
</div>
</div>
Expand All @@ -7797,7 +7797,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child">
<div class="jp-OutputPrompt jp-OutputArea-prompt"></div>
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain" tabindex="0">
<pre>/tmp/4856809_2020_01_06_00feff_global_blue_var_regridded_subsetted.tif
<pre>/tmp/4857432_2020_01_06_00feff_global_blue_var_regridded_subsetted.tif
</pre>
</div>
</div>
Expand All @@ -7810,7 +7810,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child">
<div class="jp-OutputPrompt jp-OutputArea-prompt"></div>
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain" tabindex="0">
<pre>/tmp/4856810_2020_01_07_00ffb2_global_blue_var_regridded_subsetted.tif
<pre>/tmp/4857433_2020_01_07_00ffb2_global_blue_var_regridded_subsetted.tif
</pre>
</div>
</div>
Expand All @@ -7823,7 +7823,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child">
<div class="jp-OutputPrompt jp-OutputArea-prompt"></div>
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain" tabindex="0">
<pre>/tmp/4856811_2020_01_08_00ff66_global_blue_var_regridded_subsetted.tif
<pre>/tmp/4857434_2020_01_08_00ff66_global_blue_var_regridded_subsetted.tif
</pre>
</div>
</div>
Expand All @@ -7836,7 +7836,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child">
<div class="jp-OutputPrompt jp-OutputArea-prompt"></div>
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain" tabindex="0">
<pre>/tmp/4856812_2020_01_09_00ff19_global_blue_var_regridded_subsetted.tif
<pre>/tmp/4857435_2020_01_09_00ff19_global_blue_var_regridded_subsetted.tif
</pre>
</div>
</div>
Expand Down Expand Up @@ -8009,7 +8009,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child jp-OutputArea-executeResult">
<div class="jp-OutputPrompt jp-OutputArea-prompt">Out[11]:</div>
<div class="jp-RenderedText jp-OutputArea-output jp-OutputArea-executeResult" data-mime-type="text/plain" tabindex="0">
<pre>&lt;matplotlib.image.AxesImage at 0x1271cefd0&gt;</pre>
<pre>&lt;matplotlib.image.AxesImage at 0x12cde2d50&gt;</pre>
</div>
</div>
<div class="jp-OutputArea-child">
Expand Down Expand Up @@ -8060,7 +8060,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child jp-OutputArea-executeResult">
<div class="jp-OutputPrompt jp-OutputArea-prompt">Out[12]:</div>
<div class="jp-RenderedText jp-OutputArea-output jp-OutputArea-executeResult" data-mime-type="text/plain" tabindex="0">
<pre>'3d9ff057-50af-430b-bc9c-8edd13430078'</pre>
<pre>'d5306445-54aa-4457-bf3c-9fca9d4e50e1'</pre>
</div>
</div>
</div>
Expand Down Expand Up @@ -8192,7 +8192,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputArea-child jp-OutputArea-executeResult">
<div class="jp-OutputPrompt jp-OutputArea-prompt">Out[15]:</div>
<div class="jp-RenderedText jp-OutputArea-output jp-OutputArea-executeResult" data-mime-type="text/plain" tabindex="0">
<pre>'b049d8f3-6fea-439b-aad6-60da59dcf1f7'</pre>
<pre>'91b2043e-2bf2-444a-a47a-15f0247a380a'</pre>
</div>
</div>
</div>
Expand Down Expand Up @@ -8232,7 +8232,7 @@ <h2 id="Harmony-Py-Tutorial">Harmony Py Tutorial<a class="anchor-link" href="#Ha
<div class="jp-OutputPrompt jp-OutputArea-prompt"></div>
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain" tabindex="0">
<pre>
/tmp/4856817_001_00_7f00ff_global_blue_var_regridded.nc.png
/tmp/4857440_001_00_7f00ff_global_blue_var_regridded.nc.png
</pre>
</div>
</div>
Expand Down
38 changes: 27 additions & 11 deletions examples/helper.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
import sys
sys.path.append('..')

import datetime as dt
from getpass import getpass
from glob import glob
from time import sleep

import ipyplot
from ipywidgets import IntSlider, Password, Text
from IPython.display import display, JSON
import os
import rasterio
from rasterio.plot import show
import requests

def install_project_and_dependencies(project_root, libs=None):
"""
Change to the project root, install the project and its optional dependencies,
then switch back to the original directory.
:param project_root: Path to the project root directory where pyproject.toml or setup.py is located.
:param libs: List of optional pip extra dependencies (e.g., ['examples', 'dev']).
"""
# Save the current working directory
original_dir = os.getcwd()

try:
# Change directory to the project root
os.chdir(project_root)

# If libs are specified, install them
if libs:
libs_str = ','.join(libs)
os.system(f'{sys.executable} -m pip install -q .[{libs_str}]')

# Install the project itself
os.system(f'{sys.executable} -m pip install -q .')
finally:
# Switch back to the original directory after installation
os.chdir(original_dir)


def show_result(filename):
Expand Down
10 changes: 5 additions & 5 deletions examples/tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@
},
"outputs": [],
"source": [
"import sys; sys.path.append('..')\n",
"!{sys.executable} -m pip install -q -r ../requirements/examples.txt\n",
"import helper\n",
"\n",
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel\n",
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
"# Install the project and 'examples' dependencies\n",
"helper.install_project_and_dependencies('..', libs=['examples'])\n",
"\n",
"import sys\n",
"import datetime as dt\n",
"from IPython.display import display, JSON\n",
"import rasterio\n",
"import rasterio.plot\n",
"import netCDF4 as nc4\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import helper\n",
"\n",
"\n",
"from harmony import BBox, WKT, Client, Collection, Request, Environment"
]
Expand Down
57 changes: 44 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,57 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
]
dynamic = ["dependencies", "optional-dependencies", "version"]
dynamic = ["version"]
dependencies = [
"python-dateutil ~= 2.8.2",
"python-dotenv ~= 0.20.0",
"progressbar2 ~= 4.2.0",
"requests ~= 2.32.3",
"sphinxcontrib-napoleon ~= 0.7",
"curlify ~= 2.2.1",
"shapely ~= 2.0.4"
]

[project.urls]
Homepage = "https://github.com/nasa/harmony-py"
Documentation = "https://harmony-py.readthedocs.io/en/main/"
Repository = "https://github.com/nasa/harmony-py.git"

[project.dependencies]
dependencies = ["-r requirements/core.txt"]

[project.optional-dependencies]
dev = ["-r requirements/dev.txt"]
docs = ["-r requirements/docs.txt"]
examples = ["-r requirements/examples.txt"]
dev = [
"coverage ~= 5.4",
"flake8 ~= 7.1.1",
"hypothesis ~= 6.2",
"PyYAML ~= 6.0.1",
"pytest ~= 6.2",
"pytest-cov ~= 2.11",
"pytest-mock ~= 3.5",
"pytest-watch ~= 4.2",
"responses ~= 0.25.3"
]
docs = [
"curlify ~= 2.2.1",
"Jinja2 ~= 3.1.2",
"load-dotenv ~=0.1.0",
"nbconvert ~= 7.10.0",
"progressbar2 ~= 4.2.0",
"sphinx ~= 7.1.2",
"sphinx-rtd-theme ~= 1.3.0",
"shapely ~= 2.0.4"
]
examples = [
"boto3 ~= 1.28",
"intake-stac ~= 0.4.0",
"ipyplot ~= 1.1",
"ipywidgets ~= 8.1",
"jupyterlab ~= 4.0",
"matplotlib ~= 3.8",
"netCDF4 ~= 1.6",
"numpy ~= 1.26",
"pillow ~= 10.1", # A dependency of ipyplot, pinned to avoid critical vulnerability.
"pystac ~= 1.9.0",
"rasterio ~= 1.3"
]

[tool.setuptools.dynamic]
# Will read __version__ from harmony.__init__.py
Expand All @@ -48,12 +85,6 @@ version = {attr = "harmony.__version__"}
[tool.setuptools.packages.find]
exclude = ["contrib", "docs", "tests*"]

[tool.setuptools]
include_package_data = true

[tool.setuptools.test]
test_suite = "tests"

[tool.flake8]
max-line-length = 99
ignore = ["F401", "W503"]
Expand Down
7 changes: 0 additions & 7 deletions requirements/core.txt

This file was deleted.

9 changes: 0 additions & 9 deletions requirements/dev.txt

This file was deleted.

8 changes: 0 additions & 8 deletions requirements/docs.txt

This file was deleted.

11 changes: 0 additions & 11 deletions requirements/examples.txt

This file was deleted.

0 comments on commit e9c8c07

Please sign in to comment.