Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit d40a2f6

Browse files
mike-ganglanilnatharivermartapellangachung
authored
0.4.0 release (#85)
Co-authored-by: Anil Natha <[email protected]> * Added support for custom metadata definition and search (#81) * Added support for custom metadata definition and search * Updated CHANGELOG.md * Update collection.py (#82) remove print statement that was annoying me. * Stac updates (#84) * added stac out put options to data_services call, added properties parsing to datasets * aded test dataset for properties * updated changelog * bump version * Update CHANGELOG.md Updated 0.4.0 release and date. --------- Co-authored-by: Anil Natha <[email protected]> Co-authored-by: Rishi Verma <[email protected]> Co-authored-by: Anil Natha <[email protected]> Co-authored-by: Rob Tapella <[email protected]> Co-authored-by: Nga Chung <[email protected]>
1 parent 8e70052 commit d40a2f6

File tree

12 files changed

+289
-78
lines changed

12 files changed

+289
-78
lines changed

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,25 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.4.0] - 2024-03-29
89

10+
### Added
11+
* We've added the ability to override settings in the default config file by passing in a config file with the settings needing to be overridden when instantiating a Unity object. [56](https://github.com/unity-sds/unity-py/issues/56)
12+
* Collection creation (create_collection) through dataService library
13+
* Added support for defining custom metadata for project and venue.
14+
* Added methods to return STAC content instead of unity domain objects if requested
15+
* Added properties parsing of stac metadata to dataset objects
16+
### Fixed
17+
### Changed
18+
* Updated get_collections and get_collection_data to support limit parameter.
19+
* Updated get_collection_data to support filter parameter which takes CQL string.
20+
### Removed
21+
### Security
22+
### Deprecated
23+
24+
25+
## [0.3.0] - 2024-02-12
926

10-
## Unreleased [0.3.0]
1127
### Added
1228
### Fixed
1329
* fixed an issue with encoding a json deploy request twice [71](https://github.com/unity-sds/unity-py/issues/71)

poetry.lock

Lines changed: 66 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "unity-sds-client"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
description = "Unity-Py is a Python client to simplify interactions with NASA's Unity Platform."
55
authors = ["Anil Natha, Mike Gangl"]
66
readme = "README.md"

tests/test_files/config_override.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[TEST]
2+
client_id = THIS_IS_A_TEST_CLIENT_ID
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"numberMatched":{"total_size":2},"numberReturned":2,"stac_version":"1.0.0","type":"FeatureCollection","links":[{"rel":"self","href":"https://dxebrgu0bc9w7.cloudfront.net/am-uds-dapa/collections/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/items?limit=10"},{"rel":"root","href":"https://dxebrgu0bc9w7.cloudfront.net"}],"features":[{"type":"Feature","stac_version":"1.0.0","id":"urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001","properties":{"Description":"This catalog contains the output data products of the SISTER fractional cover PGE, including a fractional cover cloud-optimized GeoTIFF. Execution artifacts including the runconfig file and execution log file are included with the fractional cover data.","soil":{"0.0":0.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"vegetation":{"0.0":0.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"water":{"0.0":0.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"snow_ice":{"0.0":1862737.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"datetime":"2024-03-19T04:54:33.703000Z","start_datetime":"2023-08-07T18:27:55Z","end_datetime":"2023-08-07T18:28:07Z","created":"2023-08-07T18:27:55Z","updated":"2024-03-19T04:55:14.767000Z","status":"completed","provider":"unity"},"geometry":{"type":"Point","coordinates":[0.0,0.0]},"links":[{"rel":"collection","href":"."},{"rel":"self","href":"https://dxebrgu0bc9w7.cloudfront.net/am-uds-dapa/collections/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/items/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001","type":"application/json","title":"urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001"}],"assets":{"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.cmr.xml":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001/SISTER_EMIT_L2B_FRCOV_20230807T182755_001.cmr.xml","title":"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.cmr.xml","description":"size=1766;checksumType=md5;checksum=bd1eec65627f63e998113952c3778f6d;","roles":["metadata"]},"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.json":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001/SISTER_EMIT_L2B_FRCOV_20230807T182755_001.json","title":"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.json","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["metadata"]},"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.tif":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001/SISTER_EMIT_L2B_FRCOV_20230807T182755_001.tif","title":"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.tif","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["data"]},"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.log":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001/SISTER_EMIT_L2B_FRCOV_20230807T182755_001.log","title":"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.log","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["metadata"]},"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.png":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001/SISTER_EMIT_L2B_FRCOV_20230807T182755_001.png","title":"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.png","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["browse"]}},"bbox":[-180.0,-90.0,180.0,90.0],"stac_extensions":[],"collection":"urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1"},{"type":"Feature","stac_version":"1.0.0","id":"urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001","properties":{"Description":"This catalog contains the output data products of the SISTER fractional cover PGE, including a fractional cover cloud-optimized GeoTIFF. Execution artifacts including the runconfig file and execution log file are included with the fractional cover data.","soil":{"0.0":0.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"vegetation":{"0.0":0.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"water":{"0.0":0.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"snow_ice":{"0.0":93871.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"datetime":"2024-03-18T18:04:15.591000Z","start_datetime":"2024-01-03T13:19:36Z","end_datetime":"2024-01-03T13:19:48Z","created":"2024-01-03T13:19:36Z","updated":"2024-03-18T18:04:27.773000Z","status":"completed","provider":"unity"},"geometry":{"type":"Point","coordinates":[0.0,0.0]},"links":[{"rel":"collection","href":"."},{"rel":"self","href":"https://dxebrgu0bc9w7.cloudfront.net/am-uds-dapa/collections/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/items/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001","type":"application/json","title":"urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001"}],"assets":{"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.cmr.xml":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001/SISTER_EMIT_L2B_FRCOV_20240103T131936_001.cmr.xml","title":"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.cmr.xml","description":"size=1766;checksumType=md5;checksum=a8c0e55579d2f1b47eb6e99188082559;","roles":["metadata"]},"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.json":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001/SISTER_EMIT_L2B_FRCOV_20240103T131936_001.json","title":"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.json","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["metadata"]},"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.tif":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001/SISTER_EMIT_L2B_FRCOV_20240103T131936_001.tif","title":"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.tif","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["data"]},"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.png":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001/SISTER_EMIT_L2B_FRCOV_20240103T131936_001.png","title":"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.png","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["browse"]},"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.log":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001/SISTER_EMIT_L2B_FRCOV_20240103T131936_001.log","title":"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.log","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["metadata"]}},"bbox":[-180.0,-90.0,180.0,90.0],"stac_extensions":[],"collection":"urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1"}]}

tests/test_unity_data_service.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from unity_sds_client.unity import Unity
2+
from unity_sds_client.unity_exception import UnityException
3+
from unity_sds_client.unity_session import UnitySession
4+
from unity_sds_client.resources.collection import Collection
5+
from unity_sds_client.unity_services import UnityServices as Services
6+
7+
import pytest
8+
9+
10+
@pytest.fixture
11+
def cleanup_update_test():
12+
yield None
13+
print("Cleanup...")
14+
15+
16+
def test_collection_creation(cleanup_update_test):
17+
#no venue, project
18+
with pytest.raises(UnityException):
19+
s = Unity()
20+
ds = s.client(Services.DATA_SERVICE)
21+
ds.create_collection(Collection("urn:nasa:unity:myproject:myvenue:identifier"), True)
22+
#no Venue
23+
with pytest.raises(UnityException):
24+
s = Unity()
25+
s.set_project("unity")
26+
ds = s.client(Services.DATA_SERVICE)
27+
ds.create_collection(Collection("urn:nasa:unity:myproject:myvenue:identifier"), True)
28+
#null collections
29+
# does not match name
30+
with pytest.raises(UnityException):
31+
s = Unity()
32+
s.set_project("unity")
33+
s.set_venue("test")
34+
ds = s.client(Services.DATA_SERVICE)
35+
ds.create_collection(None, True)
36+
37+
#does not match name
38+
with pytest.raises(UnityException):
39+
s = Unity()
40+
s.set_project("unity")
41+
s.set_venue("test")
42+
ds = s.client(Services.DATA_SERVICE)
43+
ds.create_collection( Collection("urn:nasa:unity:myproject:myvenue:identifier"), True)
44+
45+
# does not match name
46+
s = Unity()
47+
s.set_project("unity")
48+
s.set_venue("test")
49+
ds = s.client(Services.DATA_SERVICE)
50+
ds.create_collection(Collection("urn:nasa:unity:unity:test:my_collection_id"), True)

tests/test_unity_py.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def test_default_unity_client():
1616
client = Unity()
1717
assert True == True
1818

19+
def test_unity_client_config_override():
20+
client = Unity(config_file_override="tests/test_files/config_override.cfg")
21+
setting = client._session._config.get("TEST","client_id")
22+
assert setting == "THIS_IS_A_TEST_CLIENT_ID"
1923

2024
@pytest.mark.regression
2125
def test_example_regression_test(cleanup_update_test):
@@ -25,6 +29,14 @@ def test_example_regression_test(cleanup_update_test):
2529
collections = dataManager.get_collections()
2630
assert len(collections) > 0
2731

32+
@pytest.mark.regression
33+
def test_example_regression_test(cleanup_update_test):
34+
print("Example collection test")
35+
s = Unity()
36+
dataManager = s.client(Services.DATA_SERVICE)
37+
collections_json = dataManager.get_collections(output_stac=True)
38+
assert collections_json is not None
39+
2840

2941
@pytest.mark.regression
3042
def test_example_process(cleanup_update_test):

tests/test_unity_stac.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ def test_read_stac():
5656
assert len(data_files) == 1
5757
assert data_files[0].roles == ["metadata"]
5858

59+
# Try a "classic" catalog + item files stac catalog
60+
collection = Collection.from_stac("tests/test_files/dataset_with_properties.json")
61+
datasets = collection.datasets
62+
# Added 3/26/24 to check the properties being added
63+
assert datasets[0].properties is not None
64+
assert datasets[0].properties['soil']
65+
print("Properties is not null")
66+
67+
5968

6069
def test_write_stac():
6170
collection = Collection.from_stac("tests/test_files/cmr_granules.json")

unity_sds_client/resources/collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def __init__(self, id):
2828
self._beginning_time = None
2929
self._ending_time = None
3030

31+
3132
def add_dataset(self, dataset: Dataset):
3233
self._datasets.append(dataset)
3334

@@ -199,7 +200,6 @@ def from_stac(stac_file):
199200
ds = Dataset(item.id, id, item.properties.get("start_datetime", None),
200201
item.properties.get("end_datetime", None), item.properties.get("created", None))
201202
if item.collection_id is not None and item.collection_id != id:
202-
print ("if2")
203203
ds = Dataset(item.id, item.collection_id, item.properties.get("start_datetime", None),
204204
item.properties.get("end_datetime", None), item.properties.get("created", None))
205205

unity_sds_client/resources/dataset.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __str__(self):
1212
def __repr__(self):
1313
return self.__str__()
1414

15-
def __init__(self, name, collection_id, start_time, end_time, creation_time ):
15+
def __init__(self, name, collection_id, start_time, end_time, creation_time, properties=None ):
1616
"""Dataset object construction)
1717
1818
Parameters
@@ -44,6 +44,12 @@ def __init__(self, name, collection_id, start_time, end_time, creation_time ):
4444
self.geometry = None
4545
self.bbox = None
4646

47+
#add non-reserved properties
48+
if properties is not None:
49+
for key, value in properties.items():
50+
if key not in ['start_datetime','created', 'end_datetime']:
51+
self.properties[key] = value
52+
4753
def add_data_file(self, datafile: type=DataFile):
4854
"""adds a data file to a dataset
4955

0 commit comments

Comments
 (0)