Skip to content

Commit be3aea8

Browse files
authored
Merge pull request #78 from unity-sds/develop
Releast Attempt 1
2 parents 5b40733 + 84ed210 commit be3aea8

File tree

8 files changed

+570
-61
lines changed

8 files changed

+570
-61
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
===================================================================
99

10+
## [1.1.0.dev000004] - 2024-12-09
11+
### Fixed
12+
- [#76](https://github.com/unity-sds/mdps-ds-lib/pull/76) chore: update jupyter notebok
13+
14+
## [1.1.0.dev000003] - 2024-12-09
15+
### Fixed
16+
- [#72](https://github.com/unity-sds/mdps-ds-lib/pull/72) fix: remove duplicated collection id prefix
17+
18+
## [1.1.0.dev000002] - 2024-12-09
19+
### Fixed
20+
- [#71](https://github.com/unity-sds/mdps-ds-lib/pull/71) fix: no stage out file to s3 if empty
21+
22+
## [1.1.0.dev000001] - 2024-12-09
23+
### Fixed
24+
- [#70](https://github.com/unity-sds/mdps-ds-lib/pull/70) fix: catalog links should not have colon
25+
1026
## [1.1.0] - 2024-12-03
1127

1228
- [#67](https://github.com/unity-sds/mdps-ds-lib/pull/67) release 1.1.0

examples/stage-in-out-via-jupyter.ipynb

Lines changed: 344 additions & 40 deletions
Large diffs are not rendered by default.

mdps_ds_lib/stage_in_out/download_granules_abstract.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,10 @@ def download(self, **kwargs) -> str:
168168
error_list_list.append(error_list.get())
169169

170170
for each_local_stac_item in local_items_list:
171-
FileUtils.write_json(os.path.join(self._download_dir, f'{each_local_stac_item.id}.stac.json'),
171+
local_stac_item_id_updated = each_local_stac_item.id.replace(':', '-').replace('/', '-').replace('\\', '-')
172+
FileUtils.write_json(os.path.join(self._download_dir, f'{local_stac_item_id_updated}.stac.json'),
172173
each_local_stac_item.to_dict(False, False), overwrite=False, prettify=True)
173-
catalog.add_link(Link('item', f'{each_local_stac_item.id}.stac.json', 'application/json'))
174+
catalog.add_link(Link('item', f'{local_stac_item_id_updated}.stac.json', 'application/json'))
174175
self._granules_json.items = local_items_list
175176
LOGGER.debug(f'writing features collection json to downloading directory')
176177
granules_json_dict = self._granules_json.to_dict(transform_hrefs=False)

mdps_ds_lib/stage_in_out/upload_arbitrary_files_as_granules.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ def generate_sample_stac(self, filepath: str):
4242
file_checksum = FileUtils.get_checksum(filepath, True)
4343
# https://github.com/stac-extensions/file
4444
# https://github.com/stac-extensions/file/blob/main/examples/item.json
45+
granule_id = os.path.splitext(filename)[0]
46+
granule_id = granule_id if granule_id.startswith(self.__collection_id) else f'{self.__collection_id}:{granule_id}'
4547
sample_stac_item = Item(
46-
id=f'{self.__collection_id}:{os.path.splitext(filename)[0]}',
48+
id=granule_id,
4749
stac_extensions=["https://stac-extensions.github.io/file/v2.1.0/schema.json"],
4850
geometry={
4951
"type": "Point",
@@ -78,7 +80,8 @@ def execute_job(self, job_obj, lock) -> bool:
7880
updating_assets = {}
7981
try:
8082
LOGGER.audit(f'uploading auxiliary file: {job_obj}')
81-
s3_url = self.__s3.upload(job_obj, self.__staging_bucket, f'{self.__collection_id}/{self.__collection_id}:{sample_stac_item.id}', self.__delete_files)
83+
# NOTE: sample_stac_item.id is guaranteed to start with colleciton id.
84+
s3_url = self.__s3.upload(job_obj, self.__staging_bucket, f'{self.__collection_id}/{sample_stac_item.id}', self.__delete_files)
8285
updating_assets[os.path.basename(s3_url)] = s3_url
8386
uploading_current_granule_stac = f'{s3_url}.stac.json'
8487
self.__s3.set_s3_url(uploading_current_granule_stac)

mdps_ds_lib/stage_in_out/upload_granules_by_complete_catalog_s3.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,22 @@ def validate_job(self, job_obj):
5050
# return
5151

5252
def __exec_actual_job(self, each_child, lock) -> bool:
53-
current_granule_stac: Item = self.__gc.get_granules_item(each_child)
54-
current_collection_id = current_granule_stac.collection_id.strip()
53+
try:
54+
current_granule_stac: Item = self.__gc.get_granules_item(each_child)
55+
current_collection_id = current_granule_stac.collection_id.strip()
56+
except Exception as e:
57+
LOGGER.exception(f'error while processing: {each_child}')
58+
error_item = Item(id='unknown',
59+
properties={'message': 'unknown error', 'granule': each_child, 'details': str(e)},
60+
geometry={
61+
"type": "Point",
62+
"coordinates": [0.0, 0.0]
63+
},
64+
bbox=[0.0, 0.0, 0.0, 0.0],
65+
datetime=TimeUtils().parse_from_unix(0, True).get_datetime_obj(),
66+
collection='unknown')
67+
self.__error_list.put(error_item.to_dict(False, False))
68+
return True
5569
try:
5670
current_collection_id = GranulesCatalog.get_unity_formatted_collection_id(current_collection_id, self.__project_venue_set)
5771
LOGGER.debug(f'reformatted current_collection_id: {current_collection_id}')
@@ -211,14 +225,19 @@ def __actual_upload(self):
211225
FileUtils.write_json(failed_features_file, failed_item_collections.to_dict(False))
212226
if len(failed_item_collections.items) > 0:
213227
LOGGER.fatal(f'One or more Failures: {failed_item_collections.to_dict(False)}')
228+
229+
LOGGER.debug(f'creating response catalog')
230+
catalog_json = GranulesCatalog().update_catalog(catalog_file_path, [successful_features_file, failed_features_file])
231+
LOGGER.debug(f'catalog_json: {catalog_json}')
232+
if len(successful_item_collections) < 1: # TODO check this.
233+
LOGGER.debug(f'No successful items in Upload: Not uploading successful_features_ to s3://{self._staging_bucket}/{self._result_path_prefix}')
234+
return json.dumps(catalog_json)
235+
214236
s3_url = self.__s3.upload(successful_features_file, self._staging_bucket,
215237
self._result_path_prefix,
216238
s3_name=f'successful_features_{TimeUtils.get_current_time()}.json',
217239
delete_files=self._delete_files)
218240
LOGGER.debug(f'uploaded successful features to S3: {s3_url}')
219-
LOGGER.debug(f'creating response catalog')
220-
catalog_json = GranulesCatalog().update_catalog(catalog_file_path, [successful_features_file, failed_features_file])
221-
LOGGER.debug(f'catalog_json: {catalog_json}')
222241
return json.dumps(catalog_json)
223242

224243
def __exec_dry_run(self):

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 = "mdps-ds-lib"
3-
version="1.1.0"
3+
version="1.1.0.dev000004"
44
description = "Mission Data System - MDPS (Unity) Data Service Core library"
55
authors = ["Wai Phyo <wai.phyo@jpl.nasa.gov>"]
66
license = "Apache 2.0"

0 commit comments

Comments
 (0)