diff --git a/Makefile b/Makefile index e624f6a..85941f4 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ lint: flake8 harmony test: - pytest --cov=harmony tests + pytest --cov=harmony tests -W ignore::DeprecationWarning test-no-warnings: pytest --disable-warnings --cov=harmony tests diff --git a/example/example_message.json b/example/example_message.json index 0c76f87..5d3b322 100644 --- a/example/example_message.json +++ b/example/example_message.json @@ -1,5 +1,5 @@ { - "$schema": "../../harmony/app/schemas/data-operation/0.19.0/data-operation-v0.19.0.json", + "$schema": "../../harmony/services/harmony/app/schemas/data-operation/0.19.0/data-operation-v0.19.0.json", "version": "0.19.0", "callback": "http://localhost/some-path", "stagingLocation": "s3://example-bucket/public/some-org/some-service/some-uuid/", diff --git a/example/source/catalog.json b/example/source/catalog.json index 848c58b..c49be07 100644 --- a/example/source/catalog.json +++ b/example/source/catalog.json @@ -1,6 +1,9 @@ { - "stac_version": "1.0.0-beta.2", - "stac_extensions": [], + "stac_version": "1.0.0", + "stac_extensions": [ + "https://harmony.earthdata.nasa.gov/schemas/stac-extension/0.1.0/schema.json" + ], + "type": "Catalog", "id": "d5addf73-6e95-4ba1-a2a6-528de6d3d22c", "links": [ { diff --git a/example/source/catalog0.json b/example/source/catalog0.json index d4398dc..de34679 100644 --- a/example/source/catalog0.json +++ b/example/source/catalog0.json @@ -1,6 +1,9 @@ { - "stac_version": "1.0.0-beta.2", - "stac_extensions": [], + "stac_version": "1.0.0", + "stac_extensions": [ + "https://harmony.earthdata.nasa.gov/schemas/stac-extension/0.1.0/schema.json" + ], + "type": "Catalog", "id": "1bd3924c-c0ee-49b7-b9ac-0d295f4bf909", "links": [ { diff --git a/example/source/catalog1.json b/example/source/catalog1.json index 5cd647b..554a0d1 100644 --- a/example/source/catalog1.json +++ b/example/source/catalog1.json @@ -1,6 +1,9 @@ { - "stac_version": "1.0.0-beta.2", - "stac_extensions": [], + "stac_version": "1.0.0", + "stac_extensions": [ + "https://harmony.earthdata.nasa.gov/schemas/stac-extension/0.1.0/schema.json" + ], + "type": "Catalog", "id": "2bd3924c-c0ee-49b7-b9ac-0d296f4af909", "links": [ { diff --git a/example/source/granule_0_0000000.json b/example/source/granule_0_0000000.json index 24578be..7a77bd8 100644 --- a/example/source/granule_0_0000000.json +++ b/example/source/granule_0_0000000.json @@ -1,5 +1,5 @@ { - "stac_version": "1.0.0-beta.2", + "stac_version": "1.0.0", "stac_extensions": [], "id": "3ca8ec5a-6d1e-4a82-8233-313d73769e7c", "type": "Feature", diff --git a/example/source/granule_0_0000001.json b/example/source/granule_0_0000001.json index 6095239..44200b4 100644 --- a/example/source/granule_0_0000001.json +++ b/example/source/granule_0_0000001.json @@ -1,5 +1,5 @@ { - "stac_version": "1.0.0-beta.2", + "stac_version": "1.0.0", "stac_extensions": [], "id": "56e7601d-4ff0-445b-85ee-a0174558853e", "type": "Feature", diff --git a/example/source/source_0.json b/example/source/source_0.json index a7b313f..a4598bd 100644 --- a/example/source/source_0.json +++ b/example/source/source_0.json @@ -1,6 +1,7 @@ { - "stac_version": "1.0.0-beta.2", + "stac_version": "1.0.0", "stac_extensions": [], + "type": "Catalog", "id": "8bd3924c-c0ee-49b7-b9ac-0d296f4bf909", "links": [ { diff --git a/harmony/__init__.py b/harmony/__init__.py index 899d216..a73a2bd 100644 --- a/harmony/__init__.py +++ b/harmony/__init__.py @@ -12,8 +12,8 @@ from .adapter import BaseHarmonyAdapter from .cli import setup_cli, is_harmony_cli, run_cli from .message import Temporal -from pystac.stac_io import STAC_IO +from pystac.stac_io import StacIO from .s3_stac_io import read, write -STAC_IO.read_text_method = read -STAC_IO.write_text_method = write +StacIO.read_text_method = read +StacIO.write_text_method = write diff --git a/harmony/adapter.py b/harmony/adapter.py index d26efa9..e86351c 100644 --- a/harmony/adapter.py +++ b/harmony/adapter.py @@ -119,6 +119,8 @@ def invoke(self): # New-style processing using STAC if self.catalog: return (self.message, self._process_catalog_recursive(self.catalog)) + else: + warn('===========NO CATALOG ==============', DeprecationWarning, stacklevel=2) # Deprecated, processing using callbacks self._process_with_callbacks() @@ -167,6 +169,7 @@ def _process_catalog_recursive(self, catalog): pystac.Catalog A new catalog containing all of the processed results """ + warn('CLONING THE CATALOG', DeprecationWarning, stacklevel=2) result = catalog.clone() result.id = str(uuid.uuid4()) diff --git a/harmony/cli.py b/harmony/cli.py index 505ac0b..f021d59 100644 --- a/harmony/cli.py +++ b/harmony/cli.py @@ -333,12 +333,13 @@ def run_cli(parser, args, AdapterClass, cfg=None): if not successful: raise Exception('Service operation failed') else: - try: - adapter = _build_adapter(AdapterClass, + adapter = _build_adapter(AdapterClass, args.harmony_input, args.harmony_sources, args.harmony_data_location, cfg) + try: + adapter.logger.info(f'timing.{cfg.app_name}.start') _invoke(adapter, args.harmony_metadata_dir) finally: diff --git a/harmony/s3_stac_io.py b/harmony/s3_stac_io.py index 5526f39..f9309b0 100644 --- a/harmony/s3_stac_io.py +++ b/harmony/s3_stac_io.py @@ -1,6 +1,6 @@ from urllib.parse import urlparse import boto3 -from pystac import STAC_IO +from pystac.stac_io import DefaultStacIO from harmony import util from harmony import aws from os import environ @@ -35,7 +35,7 @@ def read(uri): obj = s3.Object(bucket, key) return obj.get()['Body'].read().decode('utf-8') else: - return STAC_IO.default_read_text_method(uri) + return DefaultStacIO().read_text(uri) def write(uri, txt): @@ -51,4 +51,4 @@ def write(uri, txt): if parsed.scheme == 's3': aws.write_s3(uri, txt) else: - STAC_IO.default_write_text_method(uri, txt) + DefaultStacIO().write_text_to_href(uri, txt) diff --git a/requirements.txt b/requirements.txt index b132d46..8593e11 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ boto3 ~= 1.14 deprecation ~= 2.1.0 pynacl ~= 1.4 -pystac ~= 0.5.3 +pystac ~= 1.10.0 python-json-logger ~= 2.0.1 requests ~= 2.24 urllib3 ~= 1.26.9 \ No newline at end of file diff --git a/tests/test_adapter_stac.py b/tests/test_adapter_stac.py index 6d4b803..955eac3 100644 --- a/tests/test_adapter_stac.py +++ b/tests/test_adapter_stac.py @@ -165,7 +165,7 @@ def test_get_all_items_handles_children(self, test_patch): adapter = AdapterTester(message, catalog, config=self.config) all_items = list(adapter.get_all_catalog_items(catalog, True)) self.assertEqual(all_items, [ *items_a, *items_b ]) - + def test_unaltered_ids_are_assigned_new_uuids(self): catalog = Catalog('0', 'Catalog 0') @@ -210,7 +210,8 @@ def test_legacy_invocations_create_stac_catalogs(self): self.assertEqual(AdapterTester.process_args[2][1], message.sources[1]) self.assertEqual(AdapterTester.process_args[0][0].to_dict(), { 'type': 'Feature', - 'stac_version': '1.0.0-beta.2', + 'stac_version': '1.0.0', + 'stac_extensions': [], 'id': 'G0001-EXAMPLE', 'properties': { 'start_datetime': '2001-01-01T01:01:01Z', @@ -230,7 +231,8 @@ def test_legacy_invocations_create_stac_catalogs(self): }) self.assertEqual(AdapterTester.process_args[1][0].to_dict(), { 'type': 'Feature', - 'stac_version': '1.0.0-beta.2', + 'stac_version': '1.0.0', + 'stac_extensions': [], 'id': 'G0002-EXAMPLE', 'properties': { 'start_datetime': '2003-03-03T03:03:03Z',