Skip to content

Commit 8e08e1b

Browse files
authored
Merge pull request #166 from unity-sds/develop
release/5.0.1
2 parents cc67919 + a5733ee commit 8e08e1b

File tree

6 files changed

+33
-17
lines changed

6 files changed

+33
-17
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+
## [5.0.1] - 2023-06-21
9+
### Added
10+
- [#165](https://github.com/unity-sds/unity-data-services/pull/165) fix: convert all outputs into json str
11+
812
## [5.0.0] - 2023-06-13
913
### Added
1014
- [#163](https://github.com/unity-sds/unity-data-services/pull/163) breaking: new upload implementation for complete catalog (no connection to DAPA)

cumulus_lambda_functions/stage_in_out/catalog_granules_unity.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import json
2+
13
from cumulus_lambda_functions.cumulus_dapa_client.dapa_client import DapaClient
24
from cumulus_lambda_functions.stage_in_out.catalog_granules_abstract import CatalogGranulesAbstract
35
import logging
@@ -36,4 +38,4 @@ def catalog(self, **kwargs):
3638
dapa_client = DapaClient().with_verify_ssl(self.__verify_ssl)
3739
LOGGER.debug(f'dapa_body_granules: {dapa_body}')
3840
dapa_ingest_result = dapa_client.ingest_granules_w_cnm(dapa_body)
39-
return dapa_ingest_result
41+
return json.dumps(dapa_ingest_result)

cumulus_lambda_functions/stage_in_out/download_granules_abstract.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _retrieve_stac_json(self):
6464
self._granules_json = ItemCollection.from_dict(json_stac)
6565
return self
6666

67-
def download(self, **kwargs) -> dict:
67+
def download(self, **kwargs) -> str:
6868
self._set_props_from_env()
6969
LOGGER.debug(f'creating download dir: {self._download_dir}')
7070
if len(self._granules_json.items) < 1:
@@ -88,4 +88,4 @@ def download(self, **kwargs) -> dict:
8888
if len(error_list) > 0:
8989
with open(f'{self._download_dir}/error.log', 'w') as error_file:
9090
error_file.write(json.dumps(error_list, indent=4))
91-
return granules_json_dict
91+
return json.dumps(granules_json_dict)

cumulus_lambda_functions/stage_in_out/upload_granules_by_complete_catalog_s3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __set_props_from_env(self):
4242
self.__delete_files = os.environ.get(self.DELETE_FILES_KEY, 'FALSE').strip().upper() == 'TRUE'
4343
return self
4444

45-
def upload(self, **kwargs) -> dict:
45+
def upload(self, **kwargs) -> str:
4646
self.__set_props_from_env()
4747
child_links = self.__gc.get_child_link_hrefs(os.environ.get(self.CATALOG_FILE))
4848
errors = []
@@ -81,4 +81,4 @@ def upload(self, **kwargs) -> dict:
8181
LOGGER.error(f'some errors while uploading granules: {errors}')
8282
LOGGER.debug(f'dapa_body_granules: {dapa_body_granules}')
8383
uploaded_item_collections = ItemCollection(items=dapa_body_granules)
84-
return uploaded_item_collections.to_dict(False)
84+
return json.dumps(uploaded_item_collections.to_dict(False))

setup.py

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

1919
setup(
2020
name="cumulus_lambda_functions",
21-
version="5.0.0",
21+
version="5.0.1",
2222
packages=find_packages(),
2323
install_requires=install_requires,
2424
tests_require=['mock', 'nose', 'sphinx', 'sphinx_rtd_theme', 'coverage', 'pystac', 'python-dotenv', 'jsonschema'],

tests/integration_tests/test_docker_entry.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_01_search_part_01(self):
4343
# self.assertTrue(isinstance(search_result, list), f'search_result is not list: {search_result}')
4444
self.assertEqual(len(item_collections.items), 4000, f'wrong length')
4545
search_result = set([k.id for k in item_collections.items])
46-
self.assertEqual(len(search_result),4000, f'wrong length. not unique')
46+
self.assertEqual(len(search_result), 4000, f'wrong length. not unique')
4747
self.assertTrue(FileUtils.file_exist(os.environ['OUTPUT_FILE']), f'missing output file')
4848
self.assertEqual(sorted(json.dumps(FileUtils.read_json(os.environ['OUTPUT_FILE']))), sorted(search_result_str), f'not identical result')
4949
return
@@ -226,7 +226,8 @@ def test_02_download(self):
226226
with tempfile.TemporaryDirectory() as tmp_dir_name:
227227
os.environ['OUTPUT_FILE'] = os.path.join(tmp_dir_name, 'some_output', 'output.json')
228228
os.environ['DOWNLOAD_DIR'] = tmp_dir_name
229-
download_result = choose_process()
229+
download_result_str = choose_process()
230+
download_result = json.loads(download_result_str)
230231
self.assertTrue('features' in download_result, f'missing features in download_result')
231232
self.assertEqual(len(download_result['features']) + 2, len(glob(os.path.join(tmp_dir_name, '*'))), f'downloaded file does not match')
232233
error_file = os.path.join(tmp_dir_name, 'error.log')
@@ -256,7 +257,8 @@ def test_02_download__daac(self):
256257
with tempfile.TemporaryDirectory() as tmp_dir_name:
257258
os.environ['OUTPUT_FILE'] = os.path.join(tmp_dir_name, 'some_output', 'output.json')
258259
os.environ['DOWNLOAD_DIR'] = tmp_dir_name
259-
download_result = choose_process()
260+
download_result_str = choose_process()
261+
download_result = json.loads(download_result_str)
260262
self.assertTrue('features' in download_result, f'missing features in download_result')
261263
self.assertEqual(len(download_result['features']) + 2, len(glob(os.path.join(tmp_dir_name, '*'))), f'downloaded file does not match')
262264
error_file = os.path.join(tmp_dir_name, 'error.log')
@@ -291,7 +293,8 @@ def test_02_download__daac__from_file(self):
291293
FileUtils.write_json(granule_json_file, granule_json)
292294
os.environ['STAC_JSON'] = granule_json_file
293295
os.environ['DOWNLOAD_DIR'] = downloading_dir
294-
download_result = choose_process()
296+
download_result_str = choose_process()
297+
download_result = json.loads(download_result_str)
295298
self.assertTrue('features' in download_result, f'missing features in download_result')
296299
self.assertEqual(len(download_result['features']) + 1, len(glob(os.path.join(downloading_dir, '*'))), f'downloaded file does not match')
297300
error_file = os.path.join(downloading_dir, 'error.log')
@@ -320,7 +323,8 @@ def test_02_download__daac_error(self): # TODO update this later
320323
os.environ['OUTPUT_FILE'] = os.path.join(tmp_dir_name, 'some_output', 'output.json')
321324
# TODO this is downloading a login page HTML
322325
os.environ['DOWNLOAD_DIR'] = tmp_dir_name
323-
download_result = choose_process()
326+
download_result_str = choose_process()
327+
download_result = json.loads(download_result_str)
324328
self.assertTrue(isinstance(download_result, list), f'download_result is not list: {download_result}')
325329
self.assertEqual(sum([len(k) for k in download_result]), len(glob(os.path.join(tmp_dir_name, '*'))), f'downloaded file does not match')
326330
error_file = os.path.join(tmp_dir_name, 'error.log')
@@ -344,7 +348,8 @@ def test_02_download__from_file(self):
344348
FileUtils.write_json(granule_json_file, granule_json)
345349
os.environ['STAC_JSON'] = granule_json_file
346350
os.environ['DOWNLOAD_DIR'] = downloading_dir
347-
download_result = choose_process()
351+
download_result_str = choose_process()
352+
download_result = json.loads(download_result_str)
348353
self.assertTrue('features' in download_result, f'missing features in download_result')
349354
self.assertEqual(len(download_result['features']) + 1, len(glob(os.path.join(downloading_dir, '*'))), f'downloaded file does not match')
350355
error_file = os.path.join(downloading_dir, 'error.log')
@@ -373,7 +378,8 @@ def test_02_download__from_http(self):
373378
FileUtils.write_json(granule_json_file, granule_json)
374379
os.environ['STAC_JSON'] = granule_json_file
375380
os.environ['DOWNLOAD_DIR'] = downloading_dir
376-
download_result = choose_process()
381+
download_result_str = choose_process()
382+
download_result = json.loads(download_result_str)
377383
self.assertTrue('features' in download_result, f'missing features in download_result')
378384
self.assertEqual(len(download_result['features']) + 1, len(glob(os.path.join(downloading_dir, '*'))), f'downloaded file does not match')
379385
error_file = os.path.join(tmp_dir_name, 'error.log')
@@ -836,7 +842,8 @@ def test_03_upload_complete_catalog(self):
836842
with open(os.environ['CATALOG_FILE'], 'w') as ff:
837843
ff.write(json.dumps(catalog.to_dict(False, False)))
838844

839-
upload_result = choose_process()
845+
upload_result_str = choose_process()
846+
upload_result = json.loads(upload_result_str)
840847
print(upload_result)
841848
self.assertTrue('features' in upload_result, 'missing features')
842849
self.assertEqual(1, len(upload_result['features']), 'wrong length of upload_result features')
@@ -892,7 +899,8 @@ def test_04_catalog(self):
892899
argv.append('CATALOG')
893900
with tempfile.TemporaryDirectory() as tmp_dir_name:
894901
os.environ['OUTPUT_FILE'] = os.path.join(tmp_dir_name, 'some_output', 'output.json')
895-
catalog_result = choose_process()
902+
catalog_result_str = choose_process()
903+
catalog_result = json.loads(catalog_result_str)
896904
self.assertEqual('registered', catalog_result, 'wrong status')
897905
self.assertTrue(FileUtils.file_exist(os.environ['OUTPUT_FILE']), f'missing output file')
898906
return
@@ -916,7 +924,8 @@ def test_04_catalog_from_file(self):
916924
FileUtils.write_json(input_file_path, upload_result)
917925
os.environ['UPLOADED_FILES_JSON'] = input_file_path
918926
os.environ['OUTPUT_FILE'] = os.path.join(tmp_dir_name, 'some_output', 'output.json')
919-
catalog_result = choose_process()
927+
catalog_result_str = choose_process()
928+
catalog_result = json.loads(catalog_result_str)
920929
self.assertEqual('registered', catalog_result, 'wrong status')
921930
self.assertTrue(FileUtils.file_exist(os.environ['OUTPUT_FILE']), f'missing output file')
922931
return
@@ -940,7 +949,8 @@ def test_04_catalog_from_file_item_collection(self):
940949
FileUtils.write_json(input_file_path, upload_result)
941950
os.environ['UPLOADED_FILES_JSON'] = input_file_path
942951
os.environ['OUTPUT_FILE'] = os.path.join(tmp_dir_name, 'some_output', 'output.json')
943-
catalog_result = choose_process()
952+
catalog_result_str = choose_process()
953+
catalog_result = json.loads(catalog_result_str)
944954
self.assertEqual('registered', catalog_result, 'wrong status')
945955
self.assertTrue(FileUtils.file_exist(os.environ['OUTPUT_FILE']), f'missing output file')
946956
return

0 commit comments

Comments
 (0)