From 117b8789542f9080a10ea0d8bceefda3954acdb6 Mon Sep 17 00:00:00 2001 From: Matt Savoie Date: Wed, 16 Oct 2024 11:48:04 -0600 Subject: [PATCH] Update harmony-service lib and update docker platform to amd64 (#33) --- .pre-commit-config.yaml | 8 ++++---- CHANGELOG.md | 11 ++++++++++- bin/build-image | 3 ++- bin/build-test | 3 ++- bin/run-test | 3 ++- docker/service_version.txt | 2 +- docs/HyBIG-Example-Usage.ipynb | 4 ++-- docs/requirements.txt | 2 +- harmony_service/__main__.py | 2 +- harmony_service/adapter.py | 13 +++++++++---- harmony_service/exceptions.py | 2 +- hybig/browse.py | 4 ++-- hybig/browse_utility.py | 2 +- hybig/color_utility.py | 2 +- hybig/crs.py | 2 +- hybig/sizes.py | 8 ++++++-- pip_requirements.txt | 8 ++++---- tests/test_service/test_adapter.py | 4 ++-- tests/test_service/unit/test_adapter_unit.py | 4 ++-- tests/unit/test_browse.py | 5 ++--- tests/unit/test_color_utility.py | 2 +- tests/unit/test_crs.py | 2 +- tests/unit/test_sizes.py | 2 +- tests/utilities.py | 2 +- 24 files changed, 60 insertions(+), 40 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8264876..5cc1ae3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ ci: autofix_prs: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -10,12 +10,12 @@ repos: - id: check-yaml - id: check-added-large-files - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.5 + rev: v0.6.9 hooks: - id: ruff - args: ["--fix", "--show-fixes", "--select", "I"] + args: ["--fix", "--show-fixes", "--extend-select", "I"] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.4.2 + rev: 24.10.0 hooks: - id: black-jupyter args: ["--skip-string-normalization"] diff --git a/CHANGELOG.md b/CHANGELOG.md index bf43837..444d4b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ HyBIG follows semantic versioning. All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). +## [v2.0.1] - 2024-10-06 + +### Changed + +* Updates service image to be built on AMD64. +* Updates internal libraries + + ## [v2.0.0] - 2024-07-19 **DAS-2180** - Adds pip installable library. @@ -62,7 +70,8 @@ outlined by the NASA open-source guidelines. For more information on internal releases prior to NASA open-source approval, see legacy-CHANGELOG.md. -[unreleased]:https://github.com/nasa/harmony-browse-image-generator/compare/2.0.0..HEAD +[unreleased]:https://github.com/nasa/harmony-browse-image-generator/compare/2.0.1..HEAD +[v2.0.1]:https://github.com/nasa/harmony-browse-image-generator/compare/2.0.0..2.0.1 [v2.0.0]:https://github.com/nasa/harmony-browse-image-generator/compare/1.2.2..2.0.0 [v1.2.2]: https://github.com/nasa/harmony-browse-image-generator/compare/1.2.1..1.2.2 [v1.2.1]: https://github.com/nasa/harmony-browse-image-generator/compare/1.2.0..1.2.1 diff --git a/bin/build-image b/bin/build-image index a2d4284..5d25b0b 100755 --- a/bin/build-image +++ b/bin/build-image @@ -7,6 +7,7 @@ # 2022-01-03: Updated Dockerfile path and added comments for tags. # 2023-04-04: Updated for the Harmony Browse Image Generator (HyBIG). # 2024-01-22: Updated image name to: ghcr.io/nasa/harmony-browse-image-generator. +# 2024-10-06: Updated to support amd64. # ############################################################################### @@ -29,4 +30,4 @@ tag=${1:-latest} # version number from `docker/service_version.txt`. # - "latest", so the test Dockerfile can use the service image as a base image. # -docker build -t ${image}:${tag} -t ${image}:latest -f docker/service.Dockerfile . +docker build --platform linux/amd64 -t ${image}:${tag} -t ${image}:latest -f docker/service.Dockerfile . diff --git a/bin/build-test b/bin/build-test index 519304c..8e9aacd 100755 --- a/bin/build-test +++ b/bin/build-test @@ -12,6 +12,7 @@ # 2022-01-03: Updated Dockerfile path. # 2023-04-04: Updated for the Harmony Browse Image Generator (HyBIG). # 2024-01-22: Updated image name to: ghcr.io/nasa/harony-browse-image-generator-test. +# 2024-10-06: Updated to support amd64. # ############################################################################### @@ -26,4 +27,4 @@ if [ ! -z "$old" ] && [ "$2" != "--no-delete" ]; then fi # Build the image -docker build -t ${image}:${tag} -f docker/tests.Dockerfile . +docker build --platform linux/amd64 -t ${image}:${tag} -f docker/tests.Dockerfile . diff --git a/bin/run-test b/bin/run-test index 72035c2..b9df28d 100755 --- a/bin/run-test +++ b/bin/run-test @@ -8,6 +8,7 @@ # 2021-01-05: Updated for JUnit output. # 2023-04-04: Updated for the Harmony Browse Image Generator (HyBIG). # 2024-01-23: Updated to use new GitHub-related images. +# 2024-10-06: Updated to support amd64. # ############################################################################### @@ -24,7 +25,7 @@ mkdir -p coverage # Run the tests in a Docker container with mounted volumes for XML report # output and test coverage reporting -docker run --rm \ +docker run --platform linux/amd64 --rm \ -v $(pwd)/test-reports:/home/tests/reports \ -v $(pwd)/coverage:/home/tests/coverage \ ghcr.io/nasa/harmony-browse-image-generator-test "$@" diff --git a/docker/service_version.txt b/docker/service_version.txt index 227cea2..38f77a6 100644 --- a/docker/service_version.txt +++ b/docker/service_version.txt @@ -1 +1 @@ -2.0.0 +2.0.1 diff --git a/docs/HyBIG-Example-Usage.ipynb b/docs/HyBIG-Example-Usage.ipynb index b0d3939..1fc04d9 100644 --- a/docs/HyBIG-Example-Usage.ipynb +++ b/docs/HyBIG-Example-Usage.ipynb @@ -57,11 +57,11 @@ "metadata": {}, "outputs": [], "source": [ - "from harmony import Collection, Environment, Client, Request\n", - "\n", "# creates an output directory for the downloaded files\n", "from pathlib import Path\n", "\n", + "from harmony import Client, Collection, Environment, Request\n", + "\n", "output_dir = Path('./hybig-output')\n", "Path.mkdir(output_dir, exist_ok=True)" ] diff --git a/docs/requirements.txt b/docs/requirements.txt index a03f723..3080d1a 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,2 @@ -notebook==7.0.3 +notebook==7.2.2 harmony-py~=0.4.14 diff --git a/harmony_service/__main__.py b/harmony_service/__main__.py index 5188729..79e94a8 100644 --- a/harmony_service/__main__.py +++ b/harmony_service/__main__.py @@ -3,7 +3,7 @@ from argparse import ArgumentParser from sys import argv -from harmony import is_harmony_cli, run_cli, setup_cli +from harmony_service_lib import is_harmony_cli, run_cli, setup_cli from .adapter import BrowseImageGeneratorAdapter from .exceptions import SERVICE_NAME diff --git a/harmony_service/adapter.py b/harmony_service/adapter.py index 0f4700a..89b66f4 100644 --- a/harmony_service/adapter.py +++ b/harmony_service/adapter.py @@ -12,15 +12,20 @@ from shutil import rmtree from tempfile import mkdtemp -from harmony import BaseHarmonyAdapter -from harmony.message import Source as HarmonySource -from harmony.message_utility import ( +from harmony_service_lib import BaseHarmonyAdapter +from harmony_service_lib.message import Source as HarmonySource +from harmony_service_lib.message_utility import ( has_crs, has_scale_extents, has_scale_sizes, has_valid_scale_extents, ) -from harmony.util import bbox_to_geometry, download, generate_output_filename, stage +from harmony_service_lib.util import ( + bbox_to_geometry, + download, + generate_output_filename, + stage, +) from pystac import Asset, Catalog, Item from harmony_service.exceptions import HyBIGInvalidMessageError, HyBIGServiceError diff --git a/harmony_service/exceptions.py b/harmony_service/exceptions.py index 245f177..8414914 100644 --- a/harmony_service/exceptions.py +++ b/harmony_service/exceptions.py @@ -1,6 +1,6 @@ """Module defining harmony service errors raised by HyBIG service.""" -from harmony.util import HarmonyException +from harmony_service_lib.util import HarmonyException SERVICE_NAME = 'harmony-browse-image-generator' diff --git a/hybig/browse.py b/hybig/browse.py index dedac30..c0deef7 100644 --- a/hybig/browse.py +++ b/hybig/browse.py @@ -9,8 +9,8 @@ import numpy as np import rasterio from affine import dumpsw -from harmony.message import Message as HarmonyMessage -from harmony.message import Source as HarmonySource +from harmony_service_lib.message import Message as HarmonyMessage +from harmony_service_lib.message import Source as HarmonySource from matplotlib.cm import ScalarMappable from matplotlib.colors import Normalize from numpy import ndarray diff --git a/hybig/browse_utility.py b/hybig/browse_utility.py index 6dbd8cd..67578f6 100644 --- a/hybig/browse_utility.py +++ b/hybig/browse_utility.py @@ -1,6 +1,6 @@ """Module containing utility functionality for browse generation.""" -from harmony.message import Message as HarmonyMessage +from harmony_service_lib.message import Message as HarmonyMessage def get_harmony_message_from_params(params: dict | None) -> HarmonyMessage: diff --git a/hybig/color_utility.py b/hybig/color_utility.py index 9b81c29..4efdd68 100644 --- a/hybig/color_utility.py +++ b/hybig/color_utility.py @@ -7,7 +7,7 @@ import numpy as np import requests -from harmony.message import Source as HarmonySource +from harmony_service_lib.message import Source as HarmonySource from osgeo_utils.auxiliary.color_palette import ColorPalette from pystac import Item from rasterio.io import DatasetReader diff --git a/hybig/crs.py b/hybig/crs.py index 42ef015..87bedda 100644 --- a/hybig/crs.py +++ b/hybig/crs.py @@ -10,7 +10,7 @@ """ -from harmony.message import SRS +from harmony_service_lib.message import SRS from pyproj.crs import CRS as pyCRS # pylint: disable-next=no-name-in-module diff --git a/hybig/sizes.py b/hybig/sizes.py index 6464f9a..33bfe2f 100644 --- a/hybig/sizes.py +++ b/hybig/sizes.py @@ -13,8 +13,12 @@ import numpy as np from affine import Affine -from harmony.message import Message -from harmony.message_utility import has_dimensions, has_scale_extents, has_scale_sizes +from harmony_service_lib.message import Message +from harmony_service_lib.message_utility import ( + has_dimensions, + has_scale_extents, + has_scale_sizes, +) # pylint: disable-next=no-name-in-module from rasterio.crs import CRS diff --git a/pip_requirements.txt b/pip_requirements.txt index 2642ee3..736ebe9 100644 --- a/pip_requirements.txt +++ b/pip_requirements.txt @@ -1,8 +1,8 @@ -harmony-service-lib~=1.0.27 +harmony-service-lib~=2.0.0 matplotlib==3.9.0 numpy==1.26.4 -pillow==10.3.0 +pillow==10.4.0 pyproj==3.6.1 -pystac~=0.5.6 +pystac~=1.0.1 rasterio==1.3.10 -rioxarray==0.15.5 +rioxarray==0.17.0 diff --git a/tests/test_service/test_adapter.py b/tests/test_service/test_adapter.py index e078259..aa8ec9a 100644 --- a/tests/test_service/test_adapter.py +++ b/tests/test_service/test_adapter.py @@ -7,8 +7,8 @@ from unittest.mock import call, patch import numpy as np -from harmony.message import Message -from harmony.util import config +from harmony_service_lib.message import Message +from harmony_service_lib.util import config from pystac import Catalog from rasterio.transform import array_bounds, from_bounds from rasterio.warp import Resampling diff --git a/tests/test_service/unit/test_adapter_unit.py b/tests/test_service/unit/test_adapter_unit.py index 39e358b..3cf69eb 100644 --- a/tests/test_service/unit/test_adapter_unit.py +++ b/tests/test_service/unit/test_adapter_unit.py @@ -2,8 +2,8 @@ from unittest import TestCase from unittest.mock import Mock -from harmony.message import Message -from harmony.util import config +from harmony_service_lib.message import Message +from harmony_service_lib.util import config from pystac import Asset, Item from harmony_service.adapter import BrowseImageGeneratorAdapter diff --git a/tests/unit/test_browse.py b/tests/unit/test_browse.py index cbebb5a..aab3738 100644 --- a/tests/unit/test_browse.py +++ b/tests/unit/test_browse.py @@ -8,9 +8,8 @@ from unittest.mock import MagicMock, Mock, call, patch import numpy as np -from harmony.message import SRS -from harmony.message import Message as HarmonyMessage -from harmony.message import Source as HarmonySource +from harmony_service_lib.message import Message as HarmonyMessage +from harmony_service_lib.message import Source as HarmonySource from numpy.testing import assert_array_equal from osgeo_utils.auxiliary.color_palette import ColorPalette from PIL import Image diff --git a/tests/unit/test_color_utility.py b/tests/unit/test_color_utility.py index 2f65870..d8c571c 100644 --- a/tests/unit/test_color_utility.py +++ b/tests/unit/test_color_utility.py @@ -2,7 +2,7 @@ from unittest import TestCase from unittest.mock import Mock, patch -from harmony.message import Source as HarmonySource +from harmony_service_lib.message import Source as HarmonySource from osgeo_utils.auxiliary.color_palette import ColorPalette from pystac import Asset, Item from rasterio import DatasetReader diff --git a/tests/unit/test_crs.py b/tests/unit/test_crs.py index baf4dc8..f69607f 100644 --- a/tests/unit/test_crs.py +++ b/tests/unit/test_crs.py @@ -8,7 +8,7 @@ from unittest.mock import patch from affine import Affine -from harmony.message import SRS +from harmony_service_lib.message import SRS from rasterio.crs import CRS from rioxarray import open_rasterio diff --git a/tests/unit/test_sizes.py b/tests/unit/test_sizes.py index dcfca1b..a4d0a65 100644 --- a/tests/unit/test_sizes.py +++ b/tests/unit/test_sizes.py @@ -5,7 +5,7 @@ from unittest.mock import MagicMock, patch import rasterio -from harmony.message import Message +from harmony_service_lib.message import Message from rasterio import Affine from rasterio.crs import CRS from rioxarray import open_rasterio diff --git a/tests/utilities.py b/tests/utilities.py index 0c81a58..59481f4 100644 --- a/tests/utilities.py +++ b/tests/utilities.py @@ -3,7 +3,7 @@ from collections import namedtuple from datetime import datetime -from harmony.util import bbox_to_geometry +from harmony_service_lib.util import bbox_to_geometry from pystac import Asset, Catalog, Item Granule = namedtuple('Granule', ['url', 'media_type', 'roles'])