From e2fc10cdd8ba5b920c1ff5efa6da816080e96f60 Mon Sep 17 00:00:00 2001 From: Matt Savoie Date: Mon, 7 Oct 2024 09:20:19 -0600 Subject: [PATCH] DAS-2214: Adds Prod configuration to nsidc-icesat2 tests. (#99) --- .github/pull_request_template.md | 1 + CHANGELOG.md | 9 ++ README.md | 5 +- .../NSIDC-ICESAT2_Regression.ipynb | 130 +++++++++++++++--- .../ATL12_subset_bounding_box_reference.h5 | 4 +- test/nsidc-icesat2/version.txt | 2 +- test/shared_utils/utilities.py | 17 ++- 7 files changed, 143 insertions(+), 25 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 422f169e..f00735d1 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -12,3 +12,4 @@ A short description of the changes in this PR... * [ ] Acceptance criteria met * [ ] Tests added/updated (if needed) and passing * [ ] Documentation updated (if needed) +* [ ] CHANGELOG updated with the changes for this PR diff --git a/CHANGELOG.md b/CHANGELOG.md index 455475fc..5b7c140e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ versioning. Rather than a static releases, this repository contains of a number of regression tests that are each semi-independent. This CHANGELOG file should be used to document pull requests to this repository. +## 2024-10-02 ([#99](https://github.com/nasa/harmony-regression-tests/pull/99)) + +- Adds NSIDC ICESat2 Production Regression configuration. +- Updates the `shared_utils` function `compare_results_to_reference_file_new` + to take a new optional argument `identical` which defaults to `True` but if + set to `False` the Datatree comparison falls back to an `equals` test + ignoring metadata in its reference file comparions. + + ## 2024-09-24 ([#92](https://github.com/nasa/harmony-regression-tests/pull/92)) - Adds NSIDC ICESat2 Regression test suite. diff --git a/README.md b/README.md index a65b2f73..b6a6c7a0 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,9 @@ locally in the browser against a single service regression test. ## Install Prerequisites -* [Docker](https://www.docker.com/get-started) (to run locally in docker) -* [git-lfs](https://git-lfs.com/) (to handle large files) +* [Docker](https://www.docker.com/get-started) - to run locally in docker +* [git-lfs](https://git-lfs.com/) - to handle large files +* [pre-commit](https://pre-commit.com/) - to ensure code formatting. [See below](#pre-commit-hooks). ### Cloning the repostiory. diff --git a/test/nsidc-icesat2/NSIDC-ICESAT2_Regression.ipynb b/test/nsidc-icesat2/NSIDC-ICESAT2_Regression.ipynb index 516f3070..9fa791e7 100644 --- a/test/nsidc-icesat2/NSIDC-ICESAT2_Regression.ipynb +++ b/test/nsidc-icesat2/NSIDC-ICESAT2_Regression.ipynb @@ -140,7 +140,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cc20331c-0f04-4d38-8a38-96431fde6088", + "id": "6b57af2f-0eef-4f4b-8699-4c0159c3fece", "metadata": {}, "outputs": [], "source": [ @@ -168,7 +168,7 @@ " },\n", " 'ATL12': {\n", " 'collection_concept_id': Collection(id='C1256476536-NSIDC_CUAT'),\n", - " 'granule_id': 'G1263137424-NSIDC_CUAT',\n", + " 'granule_id': 'G1263992202-NSIDC_CUAT',\n", " 'spatial': BBox(-79.0, 27.0, -77.0, 34.0),\n", " },\n", " 'ATL13': {\n", @@ -220,10 +220,109 @@ " 'shape': 'ancillary/Ross_Sea_positive_lon_only.geojson',\n", " },\n", " },\n", - "}\n", - "\n", - "\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7977dccf-9568-43ea-97c1-f8dc1bb93e6b", + "metadata": {}, + "outputs": [], + "source": [ + "production_configuration = {\n", + " 'subset_bounding_box': {\n", + " 'ATL03': {\n", + " 'collection_concept_id': Collection(id='C2596864127-NSIDC_CPRD'),\n", + " 'granule_id': 'G2632805836-NSIDC_CPRD',\n", + " 'spatial': BBox(-105.5, 40.0, -105.0, 40.005),\n", + " },\n", + " 'ATL07': {\n", + " 'collection_concept_id': Collection(id='C2713030505-NSIDC_CPRD'),\n", + " 'granule_id': 'G2738665484-NSIDC_CPRD',\n", + " 'spatial': BBox(-112.0, 80.0, -93.0, 80.3),\n", + " },\n", + " 'ATL08': {\n", + " 'collection_concept_id': Collection(id='C2613553260-NSIDC_CPRD'),\n", + " 'granule_id': 'G2645102344-NSIDC_CPRD',\n", + " 'spatial': BBox(-105.5, 40.0, -105.0, 40.25),\n", + " },\n", + " # Blocked by DAS-2244: and PROD need UMM-S configuration\n", + " # 'ATL10': {\n", + " # 'collection_concept_id': Collection(id='C2613553243-NSIDC_CPRD'),\n", + " # 'granule_id': 'G2738637140-NSIDC_CPRD',\n", + " # 'spatial': BBox(161.0, -75.0, 171.0, -74.0),\n", + " # },\n", + " 'ATL12': {\n", + " 'collection_concept_id': Collection(id='C2613553216-NSIDC_CPRD'),\n", + " 'granule_id': 'G2952685768-NSIDC_CPRD',\n", + " 'spatial': BBox(-79.0, 27.0, -77.0, 34.0),\n", + " },\n", + " 'ATL13': {\n", + " 'collection_concept_id': Collection(id='C2684928243-NSIDC_CPRD'),\n", + " 'granule_id': 'G2720556827-NSIDC_CPRD',\n", + " 'spatial': BBox(-89.0, 43.0, -75.0, 45.0),\n", + " },\n", + " },\n", + " 'subset_by_temporal_range': {\n", + " 'ATL04': {\n", + " 'collection_concept_id': Collection(id='C2613553327-NSIDC_CPRD'),\n", + " 'granule_id': 'G2634053936-NSIDC_CPRD',\n", + " 'temporal': {\n", + " 'start': datetime.fromisoformat(\"2020-04-08T08:00:00.000Z\"),\n", + " 'stop': datetime.fromisoformat(\"2020-04-08T08:05:00.000Z\"),\n", + " },\n", + " 'coords_to_rename': ['delta_time'],\n", + " },\n", + " # BLOCKED by https://bugs.earthdata.nasa.gov/browse/DAS-2233\n", + " # 'ATL08': {\n", + " # 'collection_concept_id': Collection(id='C2613553260-NSIDC_CPRD'),\n", + " # 'granule_id': 'G1261385533-NSIDC_CUAT-TBD',\n", + " # 'temporal': {\n", + " # 'start': datetime.fromisoformat(\"2022-07-31T23:01:00.000Z\"),\n", + " # 'stop': datetime.fromisoformat(\"2022-07-31T23:01:10.000Z\"),\n", + " # },\n", + " # 'coords_to_rename': [],\n", + " # },\n", + " },\n", + " 'subset_by_shapefile': {\n", + " 'ATL06': {\n", + " 'collection_concept_id': Collection(id='C2670138092-NSIDC_CPRD'),\n", + " 'granule_id': 'G2674250298-NSIDC_CPRD',\n", + " 'shape': 'ancillary/Iceland_sliver.zip',\n", + " },\n", + " 'ATL08': {\n", + " 'collection_concept_id': Collection(id='C2613553260-NSIDC_CPRD'),\n", + " 'granule_id': 'G2640057431-NSIDC_CPRD',\n", + " 'shape': 'ancillary/SriLanka_simple.kml',\n", + " },\n", + " 'ATL09': {\n", + " 'collection_concept_id': Collection(id='C2649212495-NSIDC_CPRD'),\n", + " 'granule_id': 'G2666419430-NSIDC_CPRD',\n", + " 'shape': 'ancillary/Tasmania_sliver.geojson',\n", + " },\n", + " # Blocked by DAS-2244: and PROD need UMM-S configuration\n", + " # 'ATL10': {\n", + " # 'collection_concept_id': Collection(id='C2613553243-NSIDC_CPRD'),\n", + " # 'granule_id': 'G2738637140-NSIDC_CPRD',\n", + " # 'shape': 'ancillary/Ross_Sea_positive_lon_only.geojson',\n", + " # },\n", + " },\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1bcb56c0-f6f6-411a-9bfd-3f867bfe235a", + "metadata": {}, + "outputs": [], + "source": [ "environment_configuration = {\n", + " 'https://harmony.earthdata.nasa.gov': {\n", + " **production_configuration,\n", + " 'env': Environment.PROD,\n", + " },\n", " 'https://harmony.uat.earthdata.nasa.gov': {\n", " **non_production_configuration,\n", " 'env': Environment.UAT,\n", @@ -286,7 +385,9 @@ " assert exists(\n", " test_output\n", " ), 'Unsuccessful Harmony Request: {shortname}: {test_name}'\n", - " compare_results_to_reference_file_new(test_output, test_reference)\n", + " compare_results_to_reference_file_new(\n", + " test_output, test_reference, identical=False\n", + " )\n", " print_success(f'{shortname} {test_name} test request.')\n", "\n", " print_success(f'{test_name} test suite.')\n", @@ -339,7 +440,10 @@ " test_output\n", " ), 'Unsuccessful Harmony Request: {shortname}: {test_name}'\n", " compare_results_to_reference_file_new(\n", - " test_output, test_reference, test_config['coords_to_rename']\n", + " test_output,\n", + " test_reference,\n", + " identical=False,\n", + " coordinates_to_fix=test_config['coords_to_rename'],\n", " )\n", " print_success(f'{shortname} {test_name} test request.')\n", "\n", @@ -392,7 +496,9 @@ " assert exists(\n", " test_output\n", " ), 'Unsuccessful Harmony Request: {shortname}: {test_name}'\n", - " compare_results_to_reference_file_new(test_output, test_reference, [])\n", + " compare_results_to_reference_file_new(\n", + " test_output, test_reference, identical=False, coordinates_to_fix=[]\n", + " )\n", " print_success(f'{shortname} {test_name} test request.')\n", "\n", " print_success(f'{test_name} test suite.')\n", @@ -401,14 +507,6 @@ " f'Bounding box tests not configured for environment: {harmony_environment} - skipping tests'\n", " )" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "cf49d848-f90e-46e5-b13f-5f7d1eaf9e1c", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/test/nsidc-icesat2/reference_files/ATL12_subset_bounding_box_reference.h5 b/test/nsidc-icesat2/reference_files/ATL12_subset_bounding_box_reference.h5 index 7fd1f497..ccb427a0 100644 --- a/test/nsidc-icesat2/reference_files/ATL12_subset_bounding_box_reference.h5 +++ b/test/nsidc-icesat2/reference_files/ATL12_subset_bounding_box_reference.h5 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1a0ed331540cfe70dcf714f373ec771c89d863b4573724bce73aa555b5e05d36 -size 8004873 +oid sha256:391487cb9349c85705dcddfb39b6a39e57fc2714d6ca14ec8a0bb17614d36f09 +size 8006796 diff --git a/test/nsidc-icesat2/version.txt b/test/nsidc-icesat2/version.txt index 8acdd82b..4e379d2b 100644 --- a/test/nsidc-icesat2/version.txt +++ b/test/nsidc-icesat2/version.txt @@ -1 +1 @@ -0.0.1 +0.0.2 diff --git a/test/shared_utils/utilities.py b/test/shared_utils/utilities.py index b1407ec3..391420ea 100644 --- a/test/shared_utils/utilities.py +++ b/test/shared_utils/utilities.py @@ -82,13 +82,17 @@ def compare_results_to_reference_file( def compare_results_to_reference_file_new( results_file_name: str, reference_file_name: str, - coordinates_to_fix: list[str | None] = [], + identical: bool = True, + coordinates_to_fix: list[str] | None = None, ) -> None: """Use `DataTree` functionality to compare data values, variables, coordinates, metadata, and all their corresponding attributes of downloaded results to a reference file. """ + if coordinates_to_fix is None: + coordinates_to_fix = [] + reference_groups = open_groups(reference_file_name) results_groups = open_groups(results_file_name) @@ -100,9 +104,14 @@ def compare_results_to_reference_file_new( reference_data = DataTree.from_dict(reference_groups) results_data = DataTree.from_dict(results_groups) - assert results_data.identical(reference_data), ( - 'Output and reference files ' 'do not match.' - ) + if identical: + assert results_data.identical( + reference_data + ), 'Output and reference files do not match.' + else: + assert results_data.equals( + reference_data + ), 'Output and reference files do not match.' reference_data = None results_data = None