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

Collection & STAC read/write updates #43

Merged
merged 5 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

--------

## [0.1.2] - 2023-06-28

### Added
* added method for retrieving datasets `Collection.datasets` from a collection
### Fixed
* Added some directory slash stripping to ensure no trailing slash when specifying "to_stac" output director
### Changed
* Changed name of package from unity-py to unity-sds-client

## [0.1.1] - 2023-06-27

### Added
Expand All @@ -17,8 +26,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* added dependency on pystac > 1.7.3 to unity-py
* added addition of dataset properties to stac read/write
### Fixed
* Added some directory slash stripping to ensure no trailing slash when specifying "to_stac" output director
### Changed
* all assets written out to STAC items are made relative (if they are non-URIs, relative, or exist in the same directory tree of the STAC files)
* Changed name of package from unity-py to unity-sds-client
### Removed
* Removed support for python 3.8

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "unity_py"
version = "0.1.1"
name = "unity-sds-client"
version = "0.1.2"
description = "Unity-Py is a Python client to simplify interactions with NASA's Unity Platform."
authors = ["Anil Natha, Mike Gangl"]
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_unity_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_read_corrupt_stac():
def test_read_stac():
collection = Collection.from_stac("tests/test_files/cmr_granules.json")
assert collection.collection_id == "C2011289787-GES_DISC"
datasets = collection._datasets
datasets = collection.datasets
assert len(datasets) == 2

data_files = collection.data_locations()
Expand All @@ -36,7 +36,7 @@ def test_read_stac():

#Try a "classic" catalog + item files stac catalog
collection = Collection.from_stac("tests/test_files/catalog_01.json")
datasets = collection._datasets
datasets = collection.datasets
assert len(datasets) == 1
data_files = collection.data_locations()
assert len(data_files) == 2
Expand Down
15 changes: 15 additions & 0 deletions unity_py/resources/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ def __init__(self, id):
def add_dataset(self, dataset: Dataset):
self._datasets.append(dataset)

@property
def datasets(self):
"""
A method to return the included datasets from a collection object.

Returns
-------
dataset
List of dataset objects
"""
return self._datasets

def data_locations(self, type=[]):
"""
A method to list all asset locations (data, metdata, etc)
Expand Down Expand Up @@ -66,6 +78,9 @@ def to_stac(collection, data_dir):
The location of the stac file to read.

"""
# check data dir for a dangling "/"
data_dir = data_dir.rstrip('/')

catalog = Catalog(id=collection.collection_id, description="STAC Catalog")
for dataset in collection._datasets:
updated = datetime.now(timezone.utc).isoformat().replace('+00:00', 'Z')
Expand Down