Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b0801de
feat: add AUDIT log level for upload
wphyojpl Oct 14, 2024
00d6bde
chore: update outdated tests
wphyojpl Oct 14, 2024
327ef8d
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Oct 21, 2024
6fd6910
chore: merge from develop
wphyojpl Oct 21, 2024
f77e47e
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Oct 21, 2024
a51314b
fix: allow empty str as RESULT_PATH_PREFIX & replace w/ default val
wphyojpl Oct 21, 2024
2d72378
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Oct 28, 2024
0c31b5f
Merge branch 'develop' of github.community-sds/mdps-ds-lib into develop
wphyojpl Oct 28, 2024
5701e60
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Nov 7, 2024
b429a12
erge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Nov 7, 2024
87e82ae
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Nov 26, 2024
b730339
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Nov 26, 2024
a6d89f6
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Dec 4, 2024
87a2858
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Dec 9, 2024
efb0d8c
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Dec 9, 2024
b908552
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Dec 16, 2024
b66e867
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Dec 16, 2024
51c9a9e
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Dec 16, 2024
1ca94c8
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Jan 8, 2025
9b6dc8d
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Jan 9, 2025
919b679
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Feb 10, 2025
6d95543
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Feb 12, 2025
44697a5
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Mar 18, 2025
75a0436
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Mar 24, 2025
9e35099
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Mar 24, 2025
494505d
fix: allowing optional original stac item
wphyojpl Apr 7, 2025
d8a0ff4
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Apr 7, 2025
65be24b
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Apr 7, 2025
8610202
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Apr 22, 2025
a314344
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Apr 29, 2025
9588b56
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl May 19, 2025
3f80164
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Jun 2, 2025
592967a
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Aug 21, 2025
7d0097e
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Sep 9, 2025
37e46cc
Merge branch 'develop' of github.com:unity-sds/mdps-ds-lib into develop
wphyojpl Sep 24, 2025
5a205dc
feat: add method to get single item from stac fast
wphyojpl Oct 7, 2025
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
5 changes: 5 additions & 0 deletions mdps_ds_lib/stac_fast_api_client/sfa_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@ def update_item(self, collection_id, item_id, item, update_whole=True):
my_session.headers.update({'Content-Type': 'application/json'})
response = self.create_session().put(url, json=item) if update_whole else self.create_session().patch(url, json=item)
return self._handle_response(response)

def get_item(self, collection_id, item_id, **params):
url = f"{self._base_url}/collections/{collection_id}/items/{item_id}"
response = self.create_session().get(url, params=params)
return self._handle_response(response)
73 changes: 52 additions & 21 deletions tests/mdps_ds_lib/ds_client/test_ds_client_unity.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_stac_create_collection_01(self):
return

def test_stac_fast_get_granules_01(self):
my_session = 'a888cca4-a1e0-4dfa-9f14-0b3556bd9518'
my_session = '2039aafc-94e4-49b5-a90f-9173d88c7812'
sfa_client = SFAClientFactory().get_instance(SFAClientFactory.COOKIE_AUTH, auth_key='mod_auth_openidc_session', auth_value=my_session, ds_url='https://www.dev.mdps.mcp.nasa.gov:4443', ds_stage='stac_fast_api')
my_collection = 'S1A_IW_GRDH_2SDV'
# my_collection = 'S1B_IW_GRDH_2SDV'
Expand All @@ -111,6 +111,20 @@ def test_stac_fast_get_granules_01(self):
self.assertTrue('features' in result, f'missing features in result')
return

def test_stac_fast_get_granule_01(self):
my_session = '2039aafc-94e4-49b5-a90f-9173d88c7812'
sfa_client = SFAClientFactory().get_instance(SFAClientFactory.COOKIE_AUTH, auth_key='mod_auth_openidc_session', auth_value=my_session, ds_url='https://www.dev.mdps.mcp.nasa.gov:4443', ds_stage='stac_fast_api')
my_collection = 'S1A_IW_GRDH_2SDV'
my_item = 'S1A_IW_GRDH_2SDV_20250330T171425_20250330T171445_058537_073E4F_985B-GRD_HD'
# my_collection = 'S1B_IW_GRDH_2SDV'
result = sfa_client.get_item(my_collection, my_item)
print(json.dumps(result, indent=4))
self.assertTrue('type' in result, f'missing type in result')
self.assertEqual('Feature', result['type'], 'wrong FeatureCollection')
self.assertTrue('id' in result, f'missing features in result')
self.assertEqual(my_item, result['id'], f'missing features in result')
return

def test_stac_fast_add_granules_01(self):
"""
curl -v -L -X POST 'https://www.dev.mdps.mcp.nasa.gov:4443/stac_fast_api/collections' \
Expand Down Expand Up @@ -245,28 +259,37 @@ def test_query_granules(self):
# client.collection = 'DDD-01'
# client.collection_venue = '001'
client = DsClientUser(token_retriever, 'https://d2zjsabg0fonik.cloudfront.net', 'am-uds-dapa')
client = DsClientUser(token_retriever, 'https://api.mdps.mcp.nasa.gov', 'am-uds-dapa')
# URN:NASA:UNITY:unity:ops:TRPSYL2ALLCRS1MGLOS___2/
# URN:NASA:UNITY:unity:ops:TRPSDL2ALLCRS1MGLOS___2
client.urn = 'URN'
client.org = 'NASA'
client.project = 'UNITY'
client.tenant = 'unity'
client.tenant_venue = 'ops'
client.collection = 'TRPSYL2ALLCRS1MGLOS'
client.collection = 'TRPSDL2ALLCRS1MGLOS'
client.collection_venue = '2'
result = client.query_granules(sort_keys='+properties.datetime,-id') # bbox='-114,32.5,-113,33.5'
result = client.query_granules(sort_keys='+properties.datetime,-id', limit=1000) # bbox='-114,32.5,-113,33.5'

from mdps_ds_lib.lib.utils.file_utils import FileUtils
i = 1
for each in result['features']:
from mdps_ds_lib.lib.utils.file_utils import FileUtils
FileUtils.write_json(f'/tmp/sample_granules_{i}.json', each, overwrite=True, prettify=True)
i += 1
for each in client.query_granules_next()['features']:
from mdps_ds_lib.lib.utils.file_utils import FileUtils
FileUtils.write_json(f'/tmp/sample_granules_{i}.json', each, overwrite=True, prettify=True)
FileUtils.write_json(f'/tmp/sample_granules_{i}.json', result['features'], overwrite=True, prettify=True)
while len(result['features']) > 0:
i += 1

print(json.dumps(result, indent=4))
print(json.dumps(client.query_granules_next(), indent=4))
result = client.query_granules_next()
FileUtils.write_json(f'/tmp/sample_granules_{i}.json', result['features'], overwrite=True, prettify=True)
# i = 1
# for each in result['features']:
# from mdps_ds_lib.lib.utils.file_utils import FileUtils
# FileUtils.write_json(f'/tmp/sample_granules_{i}.json', each, overwrite=True, prettify=True)
# i += 1
# for each in client.query_granules_next()['features']:
# from mdps_ds_lib.lib.utils.file_utils import FileUtils
# FileUtils.write_json(f'/tmp/sample_granules_{i}.json', each, overwrite=True, prettify=True)
# i += 1

# print(json.dumps(result, indent=4))
# print(json.dumps(client.query_granules_next(), indent=4))
return

def test_query_granules02(self):
Expand Down Expand Up @@ -386,7 +409,7 @@ def test_query_granules01(self):
token_retriever: TokenAbstract = TokenFactory().get_instance(os.getenv('TOKEN_FACTORY'))
client = DsClientUser(token_retriever, 'https://api.test.mdps.mcp.nasa.gov', 'am-uds-dapa')
# client = DsClientAdmin(token_retriever, 'http://localhost:8005', 'data')

# URN:NASA:UNITY:unity:ops:TRPSDL2ALLCRS1MGLOS___2
client.urn = 'URN'
client.org = 'NASA'
client.project = 'UNITY'
Expand Down Expand Up @@ -417,22 +440,30 @@ def test_query_single_granule01(self):

def test_archive_one(self):
os.environ['TRUST_ENV'] = 'TRUE'
# https://api.test.mdps.mcp.nasa.gov/am-uds-dapa/collections/URN:NASA:UNITY:unity:test:TRPSDL2ALLCRS1MGLOS___2/items
os.environ['TOKEN_FACTORY'] = 'COGNITO'
token_retriever: TokenAbstract = TokenFactory().get_instance(os.getenv('TOKEN_FACTORY'))
client = DsClientUser(token_retriever, 'https://api.test.mdps.mcp.nasa.gov', 'am-uds-dapa')
# client = DsClientAdmin(token_retriever, 'http://localhost:8005', 'data')

client = DsClientUser(token_retriever, 'https://d2zjsabg0fonik.cloudfront.net', 'am-uds-dapa')
client = DsClientUser(token_retriever, 'https://api.mdps.mcp.nasa.gov', 'am-uds-dapa')
# URN:NASA:UNITY:unity:ops:TRPSYL2ALLCRS1MGLOS___2/
# URN:NASA:UNITY:unity:ops:TRPSDL2ALLCRS1MGLOS___2
client.urn = 'URN'
client.org = 'NASA'
client.project = 'UNITY'
client.tenant = 'unity'
client.tenant_venue = 'test'
client.tenant_venue = 'ops'
client.collection = 'TRPSDL2ALLCRS1MGLOS'
client.collection_venue = '2'
client.granule = 'TROPESS_CrIS-JPSS1_L2_Standard_NH3_20250108_MUSES_R1p23_megacity_los_angeles_MGLOS_F2p5_J0'
client.granule = 'TROPESS_CrIS-JPSS1_L2_Standard_TATM_20250108_MUSES_R1p23_megacity_los_angeles_MGLOS_F2p5_J0'
print(client.archive_granule())

granules = ['TROPESS_CrIS-JPSS1_L2_Standard_CH4_20250115_MUSES_R1p23_SC_MGLOS_F2p9_J0',
'TROPESS_CrIS-JPSS1_L2_Standard_TATM_20250114_MUSES_R1p23_SC_MGLOS_F2p9_J0',
'TROPESS_CrIS-JPSS1_L2_Standard_H2O_20250118_MUSES_R1p23_SC_MGLOS_F2p9_J0',
'TROPESS_CrIS-JPSS1_L2_Standard_CO_20250118_MUSES_R1p23_SC_MGLOS_F2p9_J0',
'TROPESS_CrIS-JPSS1_L2_Standard_TATM_20250118_MUSES_R1p23_SC_MGLOS_F2p9_J0']
granules = [] # TODO remove this to run again
for each in granules:
client.granule = each
print(client.archive_granule())
return

def test_add_archive_config(self):
Expand Down