Skip to content

Commit

Permalink
ADS-342 - Add regression test for opera-rtc-s1-browse
Browse files Browse the repository at this point in the history
* update gitattributes for opera-rtc-s1-browse regression test
* add regression test for opera-rtc-s1-browse
* upgrade opera-rtc-s1-browse test to harmony-py 0.5.0
* add opera-rtc-s1-browse to build-all-images.yml
* add opera-rtc-s1-browse to notebook-test-suite.yml
* remove unused import
* apply black line length recommendations
* [pre-commit.ci] auto fixes from pre-commit.com hooks

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
asjohnston-asf and pre-commit-ci[bot] authored Nov 27, 2024
1 parent 63bacda commit 35a7b3e
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
test/nsidc-icesat2/reference_files/*.h5 filter=lfs diff=lfs merge=lfs -text
test/subset-band-name/reference_data/*.hdf filter=lfs diff=lfs merge=lfs -text
test/opera-rtc-s1-browse/reference_data/*.png filter=lfs diff=lfs merge=lfs -text
4 changes: 4 additions & 0 deletions .github/workflows/build-all-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ jobs:
-
image: "net2cog"
notebook: "net2cog_Regression.ipynb"
-
image: "opera-rtc-s1-browse"
notebook: "opera-rtc-s1-browse_Regression.ipynb"
lfs: "true"

uses: ./.github/workflows/build-target-image.yml
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/notebook-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ on:
- subset-band-name
- swath-projector
- trajectory-subsetter
- opera-rtc-s1-browse
docker-image-tag:
description: "Optional Docker image tag to use for the tests"
required: false
type: string
default: 'latest'

repository_dispatch:
types: [all,geoloco,harmony-gdal-adapter,harmony-netcdf-to-zarr,harmony-service-example,hoss,hybig,net2cog,swath-projector,trajectory-subsetter]
types: [all,geoloco,harmony-gdal-adapter,harmony-netcdf-to-zarr,harmony-service-example,hoss,hybig,net2cog,swath-projector,trajectory-subsetter,opera-rtc-s1-browse]
inputs:
harmony-environment:
required: true
Expand Down
5 changes: 3 additions & 2 deletions config/services_tests_config_prod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"all": "harmony,harmony-regression,geoloco,hga,n2z,regridder,hoss,hybig,net2cog,subset-band-name,swath-projector,nsidc-icesat2,trajectory-subsetter",
"all": "harmony,harmony-regression,geoloco,hga,n2z,regridder,hoss,hybig,net2cog,subset-band-name,swath-projector,nsidc-icesat2,trajectory-subsetter,opera-rtc-s1-browse",
"batchee": "TBD",
"geoloco": "geoloco",
"giovanni-adapter": "TBD",
Expand All @@ -17,5 +17,6 @@
"stitchee": "TBD",
"subset-band-name": "subset-band-name",
"swath-projector": "swath-projector",
"trajectory-subsetter": "nsidc-icesat2,trajectory-subsetter"
"trajectory-subsetter": "nsidc-icesat2,trajectory-subsetter",
"opera-rtc-s1-browse": "opera-rtc-s1-browse"
}
5 changes: 3 additions & 2 deletions config/services_tests_config_uat.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"all": "harmony,harmony-regression,geoloco,hga,n2z,regridder,hoss,variable-subsetter,hybig,net2cog,subset-band-name,swath-projector,nsidc-icesat2,trajectory-subsetter",
"all": "harmony,harmony-regression,geoloco,hga,n2z,regridder,hoss,variable-subsetter,hybig,net2cog,subset-band-name,swath-projector,nsidc-icesat2,trajectory-subsetter,opera-rtc-s1-browse",
"batchee": "TBD",
"geoloco": "geoloco",
"giovanni-adapter": "TBD",
Expand All @@ -17,5 +17,6 @@
"stitchee": "TBD",
"subset-band-name": "subset-band-name",
"swath-projector": "swath-projector",
"trajectory-subsetter": "nsidc-icesat2,trajectory-subsetter"
"trajectory-subsetter": "nsidc-icesat2,trajectory-subsetter",
"opera-rtc-s1-browse": "opera-rtc-s1-browse"
}
2 changes: 1 addition & 1 deletion script/test-in-bamboo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ echo "harmony host url: ${harmony_host_url}"
## e.g. if REGRESSION_TESTS_N2Z_IMAGE environment was set, the value would be used instead of the default.

image_names=()
all_tests=(harmony harmony-regression hoss hga n2z nsidc-icesat2 swath-projector trajectory-subsetter variable-subsetter regridder hybig geoloco net2cog subset-band-name)
all_tests=(harmony harmony-regression hoss hga n2z nsidc-icesat2 swath-projector trajectory-subsetter variable-subsetter regridder hybig geoloco net2cog subset-band-name opera-rtc-s1-browse)
for image in "${all_tests[@]}"; do
image_names+=($(image_name "$image" true))
done
Expand Down
7 changes: 6 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ net2cog-image: Dockerfile net2cog/environment.yaml
docker build -t ghcr.io/nasa/regression-tests-net2cog:latest -f ./Dockerfile \
--build-arg notebook=net2cog_Regression.ipynb --build-arg sub_dir=net2cog .

opera-rtc-s1-browse-image: Dockerfile opera-rtc-s1-browse/environment.yaml
docker build -t ghcr.io/nasa/regression-tests-opera-rtc-s1-browse:latest -f ./Dockerfile \
--build-arg notebook=opera-rtc-s1-browse_Regression.ipynb --build-arg sub_dir=opera-rtc-s1-browse .

images: harmony-image \
harmony-regression-image \
hga-image \
Expand All @@ -70,4 +74,5 @@ images: harmony-image \
trajectory-subsetter-image \
variable-subsetter-image \
geoloco-image \
net2cog-image
net2cog-image \
opera-rtc-s1-browse-image
10 changes: 10 additions & 0 deletions test/opera-rtc-s1-browse/environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: papermill-opera-rtc-s1-browse
channels:
- conda-forge
- nodefaults
dependencies:
- python=3.12
- pip=24.3.1
- notebook=7.2.2
- papermill=2.6.0
- harmony-py==0.5.0
91 changes: 91 additions & 0 deletions test/opera-rtc-s1-browse/opera-rtc-s1-browse_Regression.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "24ad02a3-f52b-4e10-8654-e28d3e998c59",
"metadata": {
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"harmony_host_url = 'https://harmony.uat.earthdata.nasa.gov'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9692ec8e-89e4-4742-9b11-57a8644cd770",
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"from tempfile import TemporaryDirectory\n",
"\n",
"import harmony\n",
"\n",
"\n",
"environments = {\n",
" 'http://localhost:3000': harmony.Environment.LOCAL,\n",
" 'https://harmony.sit.earthdata.nasa.gov': harmony.Environment.SIT,\n",
" 'https://harmony.uat.earthdata.nasa.gov': harmony.Environment.UAT,\n",
" 'https://harmony.earthdata.nasa.gov': harmony.Environment.PROD,\n",
"}\n",
"assert harmony_host_url in environments\n",
"harmony_client = harmony.Client(env=environments[harmony_host_url])\n",
"\n",
"request = harmony.Request(\n",
" collection=harmony.Collection(id='OPERA_L2_RTC-S1_V1'),\n",
" granule_name=[\n",
" 'OPERA_L2_RTC-S1_T035-073251-IW2_20240512T020817Z_20240512T122756Z_S1A_30_v1.0'\n",
" ],\n",
" format='image/png',\n",
")\n",
"job_id = harmony_client.submit(request)\n",
"harmony_client.wait_for_processing(job_id)\n",
"\n",
"with TemporaryDirectory() as temp_dir:\n",
" output_files = [\n",
" Path(future.result())\n",
" for future in harmony_client.download_all(job_id, directory=temp_dir)\n",
" ]\n",
"\n",
" assert len(output_files) == 3\n",
" assert output_files[0].suffixes == ['.png']\n",
" assert output_files[1].suffixes == ['.pgw']\n",
" assert output_files[2].suffixes == ['.png', '.aux', '.xml']\n",
"\n",
" reference_data = Path('reference_data')\n",
" assert output_files[0].read_bytes() == (reference_data / 'rgb.png').read_bytes()\n",
" assert output_files[1].read_bytes() == (reference_data / 'rgb.pgw').read_bytes()\n",
" assert (\n",
" output_files[2].read_bytes()\n",
" == (reference_data / 'rgb.png.aux.xml').read_bytes()\n",
" )"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
6 changes: 6 additions & 0 deletions test/opera-rtc-s1-browse/reference_data/rgb.pgw
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
0.0002746658541715035
0.0
0.0
-0.00027463466178079705
-122.96676772672274
38.05992846197979
3 changes: 3 additions & 0 deletions test/opera-rtc-s1-browse/reference_data/rgb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions test/opera-rtc-s1-browse/reference_data/rgb.png.aux.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<PAMDataset>
<SRS dataAxisToSRSAxisMapping="2,1">GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]</SRS>
<GeoTransform> -1.2296690505964982e+02, 2.7466585417150349e-04, 0.0000000000000000e+00, 3.8060065779310676e+01, 0.0000000000000000e+00, -2.7463466178079705e-04</GeoTransform>
</PAMDataset>
1 change: 1 addition & 0 deletions test/opera-rtc-s1-browse/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
2 changes: 1 addition & 1 deletion test/run_notebooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ echo "Running regression tests"

# Specify the test images to run, by default all built by the Makefile. If
# the script is invoked with a list of images, only run those.
all_images=(harmony harmony-regression hoss hga n2z nsidc-icesat2 swath-projector trajectory-subsetter variable-subsetter regridder hybig geoloco net2cog subset-band-name)
all_images=(harmony harmony-regression hoss hga n2z nsidc-icesat2 swath-projector trajectory-subsetter variable-subsetter regridder hybig geoloco net2cog subset-band-name opera-rtc-s1-browse)
specified_images=()
# Parse command line arguments
while [[ $# -gt 0 ]]; do
Expand Down

0 comments on commit 35a7b3e

Please sign in to comment.