Skip to content

Commit 1d5a0ca

Browse files
authored
feat: reduce pystac length by keeping only data asset (#126)
* feat: reduce pystac length by keeping only data asset * chore: update version
1 parent 6fbfa44 commit 1d5a0ca

File tree

6 files changed

+38
-4
lines changed

6 files changed

+38
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ 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+
## [3.1.0] - 2023-01-23
9+
### Added
10+
- [#126](https://github.com/unity-sds/unity-data-services/pull/126) reduce pystac length by keeping only data asset
11+
812
## [3.0.0] - 2023-03-27
913
### Breaking
1014
- [#124](https://github.com/unity-sds/unity-data-services/pull/124) configurable file postfixes for PDS metadata extraction + rename function names which will break previous terraforms

cumulus_lambda_functions/cumulus_stac/item_transformer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,5 +409,5 @@ def to_stac(self, source: dict) -> dict:
409409
]
410410
return stac_item.to_dict(include_self_link=False, transform_hrefs=False)
411411

412-
def from_stac(self, source: dict) -> dict:
413-
return {}
412+
def from_stac(self, source: dict) -> Item:
413+
return Item.from_dict(source)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from cumulus_lambda_functions.cumulus_stac.item_transformer import ItemTransformer
2+
3+
4+
class StacUtils:
5+
@staticmethod
6+
def reduce_stac_list_to_data_links(input_stac_granules_list: [dict]):
7+
"""
8+
:param input_stac_granules_list: list of pystac dictionaries
9+
:return: [dict] - list of assets which has data key
10+
"""
11+
pystac_items = [ItemTransformer().from_stac(k) for k in input_stac_granules_list]
12+
assets = [k.get_assets() for k in pystac_items]
13+
data_assets = [{'assets': {'data': k['data'].to_dict()}} for k in assets if 'data' in k]
14+
return data_assets

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name="cumulus_lambda_functions",
20-
version="3.0.0",
20+
version="3.1.0",
2121
packages=find_packages(),
2222
install_requires=install_requires,
2323
tests_require=['mock', 'nose', 'sphinx', 'sphinx_rtd_theme', 'coverage', 'pystac', 'python-dotenv', 'jsonschema'],

tests/cumulus_lambda_functions/cumulus_stac/test_stac_utils.py

Lines changed: 15 additions & 0 deletions
Large diffs are not rendered by default.

tests/integration_tests/test_docker_entry.py

Lines changed: 2 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)