Skip to content

feat: reduce pystac length by keeping only data asset #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.1.0] - 2023-01-23
### Added
- [#126](https://github.com/unity-sds/unity-data-services/pull/126) reduce pystac length by keeping only data asset

## [3.0.0] - 2023-03-27
### Breaking
- [#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
Expand Down
4 changes: 2 additions & 2 deletions cumulus_lambda_functions/cumulus_stac/item_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,5 +409,5 @@ def to_stac(self, source: dict) -> dict:
]
return stac_item.to_dict(include_self_link=False, transform_hrefs=False)

def from_stac(self, source: dict) -> dict:
return {}
def from_stac(self, source: dict) -> Item:
return Item.from_dict(source)
14 changes: 14 additions & 0 deletions cumulus_lambda_functions/cumulus_stac/stac_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from cumulus_lambda_functions.cumulus_stac.item_transformer import ItemTransformer


class StacUtils:
@staticmethod
def reduce_stac_list_to_data_links(input_stac_granules_list: [dict]):
"""
:param input_stac_granules_list: list of pystac dictionaries
:return: [dict] - list of assets which has data key
"""
pystac_items = [ItemTransformer().from_stac(k) for k in input_stac_granules_list]
assets = [k.get_assets() for k in pystac_items]
data_assets = [{'assets': {'data': k['data'].to_dict()}} for k in assets if 'data' in k]
return data_assets
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setup(
name="cumulus_lambda_functions",
version="3.0.0",
version="3.1.0",
packages=find_packages(),
install_requires=install_requires,
tests_require=['mock', 'nose', 'sphinx', 'sphinx_rtd_theme', 'coverage', 'pystac', 'python-dotenv', 'jsonschema'],
Expand Down
15 changes: 15 additions & 0 deletions tests/cumulus_lambda_functions/cumulus_stac/test_stac_utils.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion tests/integration_tests/test_docker_entry.py

Large diffs are not rendered by default.