Skip to content

Commit 74c0c73

Browse files
authored
Merge pull request #572 from unity-sds/develop
release/9.11.5
2 parents 464abc4 + 2548f1b commit 74c0c73

File tree

13 files changed

+163
-19
lines changed

13 files changed

+163
-19
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ 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+
## [9.11.5] - 2025-04-24
9+
### Fixed
10+
- [#568](https://github.com/unity-sds/unity-data-services/pull/568) fix: case insensitive
11+
12+
## [9.11.4] - 2025-04-23
13+
### Fixed
14+
- [#569](https://github.com/unity-sds/unity-data-services/pull/569) fix: healthcheck update
15+
16+
## [9.11.3] - 2025-04-21
17+
### Fixed
18+
- [#565](https://github.com/unity-sds/unity-data-services/pull/565) fix: data service version endpoint
19+
20+
## [9.11.2] - 2025-04-15
21+
### Fixed
22+
- [#564](https://github.com/unity-sds/unity-data-services/pull/564) fix: check collection when querying single granule
23+
824
## [9.11.1] - 2025-04-10
925
### Fixed
1026
- [#561](https://github.com/unity-sds/unity-data-services/pull/561) fix: docker error

ci.cd/create_aws_lambda_zip.sh

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,28 @@
22

33
apt-get update -y && apt-get install zip -y
44

5+
# github.job
6+
github_branch=${GITHUB_REF##*/}
7+
software_version_trailing=""
8+
main_branch="main"
9+
if [ "$github_branch" = "$main_branch" ];
10+
then
11+
software_version=""
12+
else
13+
software_version_trailing="-${github_branch}-${GITHUB_RUN_ID}"
14+
fi
15+
516
ZIP_NAME='cumulus_lambda_functions_deployment.zip'
617
TERRAFORM_ZIP_NAME='terraform_cumulus_lambda_functions_deployment.zip'
718
TERRAFORM_MARKETPLACE_ZIP_NAME='terraform_marketplace_deployment.zip'
819
TERRAFORM_ECR_ZIP_NAME='terraform_ecr_deployment.zip'
920
TERRAFORM_STAC_BR_ZIP_NAME='terraform_stac_br_deployment.zip'
1021

1122
project_root_dir=${GITHUB_WORKSPACE}
23+
24+
software_version=`python3 ${project_root_dir}/setup.py --version`
25+
echo "software_version=${software_version}${software_version_trailing}" >> ${GITHUB_ENV}
26+
1227
zip_file="${project_root_dir}/$ZIP_NAME" ; # save the result file in current working directory
1328
terraform_zip_file="${project_root_dir}/$TERRAFORM_ZIP_NAME" ; # save the result file in current working directory
1429
terraform_marketplace_zip_file="${project_root_dir}/$TERRAFORM_MARKETPLACE_ZIP_NAME" ; # save the result file in current working directory
@@ -18,6 +33,13 @@ terraform_stac_br_zip_file="${project_root_dir}/$TERRAFORM_STAC_BR_ZIP_NAME" ; #
1833
source_dir=`python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'`
1934

2035
cd ${source_dir}
36+
built_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
37+
cat <<EOF > ds_version.json
38+
{
39+
"version": "$software_version",
40+
"built": "$built_time"
41+
}
42+
EOF
2143
rm -rf ${zip_file} && \
2244
zip -r9 ${zip_file} . && \
2345
echo "zipped to ${zip_file}"
@@ -38,16 +60,5 @@ zip -9 ${terraform_ecr_zip_file} * **/*
3860
cd $project_root_dir/tf-module/stac_browser
3961
zip -9 ${terraform_stac_br_zip_file} * **/*
4062

41-
# github.job
42-
github_branch=${GITHUB_REF##*/}
43-
software_version_trailing=""
44-
main_branch="main"
45-
if [ "$github_branch" = "$main_branch" ];
46-
then
47-
software_version=""
48-
else
49-
software_version_trailing="-${github_branch}-${GITHUB_RUN_ID}"
50-
fi
51-
software_version=`python3 ${project_root_dir}/setup.py --version`
52-
echo "software_version=${software_version}${software_version_trailing}" >> ${GITHUB_ENV}
63+
5364
cat ${GITHUB_ENV}

cumulus_lambda_functions/lib/uds_db/uds_collections.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ def get_collections(self, collection_regex: list):
107107
'query': {
108108
'bool': {
109109
'should': [
110-
{'regexp': {DBConstants.collection_id: k}} for k in collection_regex
110+
{'regexp': {DBConstants.collection_id: {
111+
'value': k,
112+
'case_insensitive': True
113+
}}} for k in collection_regex
111114
]
112115
}
113116
},

cumulus_lambda_functions/uds_api/dapa/granules_dapa_query_es.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ def get_single_granule(self, granule_id):
172172
'size': 1,
173173
'sort': [{'id': {'order': 'asc'}}],
174174
'query': {'bool': {'must': [{
175-
'term': {'id': granule_id}
175+
'term': {'id': granule_id}}, {
176+
'term': {'collection': self.__collection_id},
176177
}]}}
177178
}
178179
LOGGER.debug(f'granules_query_dsl: {granules_query_dsl}')
@@ -182,7 +183,7 @@ def get_single_granule(self, granule_id):
182183
granules_query_dsl)
183184
LOGGER.debug(f'granules_query_result: {granules_query_result}')
184185
if len(granules_query_result['hits']['hits']) < 1:
185-
raise ValueError(f'cannot find granule for : {granule_id}')
186+
return None
186187

187188
each_granules_query_result_stripped = granules_query_result['hits']['hits'][0]['_source']
188189
self_link = Link(rel='self', target=f'{self.__base_url}/{WebServiceConstants.COLLECTIONS}/{self.__collection_id}/items/{each_granules_query_result_stripped["id"]}', media_type='application/json', title=each_granules_query_result_stripped["id"]).to_dict(False)

cumulus_lambda_functions/uds_api/granules_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ async def get_single_granule_dapa(request: Request, collection_id: str, granule_
136136
except Exception as e:
137137
LOGGER.exception('failed during get_granules_dapa')
138138
raise HTTPException(status_code=500, detail=str(e))
139+
if granules_result is None:
140+
raise HTTPException(status_code=404, detail={'message': f'no granule with id: {granule_id} in collection: {collection_id}'})
139141
return granules_result
140142

141143
@router.delete("/{collection_id}/items/{granule_id}")

cumulus_lambda_functions/uds_api/misc_api.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import json
22
import os
3+
from glob import glob
34
from time import time
45
from typing import Union
56

7+
from mdps_ds_lib.lib.utils.file_utils import FileUtils
68
from starlette.responses import Response, RedirectResponse
79
from cumulus_lambda_functions.uds_api.fast_api_utils import FastApiUtils
810

@@ -50,6 +52,7 @@ async def catalog_list(request: Request, response: Response):
5052
}]
5153
return stac_browser_expecting_result
5254

55+
5356
@router.get(f'/stac_entry')
5457
@router.get(f'/stac_entry/')
5558
async def stac_entry(request: Request, response: Response):
@@ -79,3 +82,29 @@ async def stac_entry(request: Request, response: Response):
7982
redirect_response.set_cookie(key="unity_token", value=request_headers['oidc_access_token'], httponly=False, secure=False, samesite='strict') # missing , domain=base_url
8083
redirect_response.set_cookie(key="test1", value=f"{time()}", httponly=False, secure=False, samesite='strict') # missing , domain=base_url
8184
return redirect_response
85+
86+
87+
@router.get(f'/version')
88+
@router.get(f'/version/')
89+
async def ds_version(request: Request, response: Response):
90+
"""
91+
This is to list all catalogs for STAC Browser.
92+
This doesn't require any authorization token.
93+
:param request:
94+
:param response:
95+
:return:
96+
"""
97+
version_details_unknown = {
98+
'version': 'unknown',
99+
'built': 'unknown'
100+
}
101+
if not FileUtils.file_exist('/var/task/ds_version.json'):
102+
print(f'missing file : {[k for k in glob("/var/task/*.json")]}')
103+
return version_details_unknown
104+
version_details = FileUtils.read_json('/var/task/ds_version.json')
105+
106+
version_details = {
107+
**version_details_unknown,
108+
**version_details,
109+
}
110+
return version_details

cumulus_lambda_functions/uds_api/web_service.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ async def get_open_api(request: Request):
6464
default_open_api_doc['paths'].pop(k)
6565
return app.openapi()
6666

67-
6867
# to make it work with Amazon Lambda, we create a handler object
6968
handler = Mangum(app=app)
7069

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jsonschema==4.23.0
1515
jsonschema-specifications==2023.12.1
1616
lark==0.12.0
1717
mangum==0.18.0
18-
mdps-ds-lib==1.1.1.dev700
18+
mdps-ds-lib==1.1.1.dev701
1919
pydantic==2.9.2
2020
pydantic_core==2.23.4
2121
pygeofilter==0.2.4

setup.py

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

1313
setup(
1414
name="cumulus_lambda_functions",
15-
version="9.11.1",
15+
version="9.11.5",
1616
packages=find_packages(),
1717
install_requires=install_requires,
1818
package_data={

tests/integration_tests/test_uds_api.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,40 @@ def test_single_granule_get(self):
233233

234234
return
235235

236+
def test_version_get(self):
237+
post_url = f'{self.uds_url}misc/version/'
238+
headers = {
239+
'Authorization': f'Bearer {self.bearer_token}',
240+
}
241+
print(post_url)
242+
query_result = requests.get(url=post_url,
243+
headers=headers,
244+
)
245+
# self.assertEqual(query_result.status_code, 200, f'wrong status code. {query_result.text}')
246+
response_json = json.loads(query_result.text)
247+
print(json.dumps(response_json))
248+
return
249+
250+
251+
def test_single_granule_get_wrong_collection(self):
252+
# post_url = f'{self.uds_url}collections/urn:nasa:unity:uds_local_test:DEV1:CHRP_16_DAY_REBIN___10/items/urn:nasa:unity:uds_local_test:DEV1:CHRP_16_DAY_REBIN___10:SNDR.SS1330.CHIRP.20230101T0000.m06.g001.L1_J1.std.v02_48.G.200101070318_REBIN'
253+
post_url = f'{self.uds_url}collections/URN:NASA:UNITY:UDS_LOCAL_TEST_3:DEV:DDD-02___001/items/URN:NASA:UNITY:UDS_LOCAL_TEST_3:DEV:DDD-01___001:test_file10'
254+
headers = {
255+
'Authorization': f'Bearer {self.bearer_token}',
256+
}
257+
print(post_url)
258+
query_result = requests.get(url=post_url, headers=headers,)
259+
self.assertEqual(query_result.status_code, 404, f'wrong status code. {query_result.text}')
260+
response_json = json.loads(query_result.text)
261+
print(json.dumps(response_json))
262+
263+
post_url = f'{self.uds_url}collections/URN:NASA:UNITY:UDS_LOCAL_TEST_3:DEV:DDD-01___001/items/URN:NASA:UNITY:UDS_LOCAL_TEST_3:DEV:DDD-01___001:test_file10'
264+
query_result = requests.get(url=post_url, headers=headers,)
265+
self.assertEqual(query_result.status_code, 200, f'wrong status code. {query_result.text}')
266+
response_json = json.loads(query_result.text)
267+
print(json.dumps(response_json))
268+
return
269+
236270
def test_create_new_collection(self):
237271
post_url = f'{self.uds_url}collections/' # MCP Dev
238272
headers = {

tf-module/unity-cumulus/api_gateway.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ resource "aws_api_gateway_deployment" "shared_services_api_gateway_deployment" {
5454

5555
aws_api_gateway_integration.misc_catalog_list_lambda_integration,
5656
aws_api_gateway_integration.misc_stac_entry_lambda_integration,
57+
aws_api_gateway_integration.misc_version_lambda_integration,
5758

5859
aws_api_gateway_integration.stac_browser_lambda_integration,
5960
aws_api_gateway_integration.stac_browser_proxy_lambda_integration,
6061

62+
6163
module.uds_all_cors_method.options_integration_object,
6264
module.uds_all_any_to_lambda_module.lambda_integration_object,
6365

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
resource "aws_api_gateway_resource" "misc_version_resource" {
2+
rest_api_id = data.aws_api_gateway_rest_api.rest_api.id
3+
parent_id = aws_api_gateway_resource.misc_base_resource.id
4+
path_part = "version"
5+
}
6+
7+
resource "aws_api_gateway_method" "misc_version_method" {
8+
rest_api_id = data.aws_api_gateway_rest_api.rest_api.id
9+
resource_id = aws_api_gateway_resource.misc_version_resource.id
10+
http_method = "GET"
11+
authorization = "NONE"
12+
request_parameters = {
13+
"method.request.path.proxy" = true
14+
}
15+
}
16+
17+
resource "aws_api_gateway_method_response" "misc_version_method_response" {
18+
rest_api_id = data.aws_api_gateway_rest_api.rest_api.id
19+
resource_id = aws_api_gateway_resource.misc_version_resource.id
20+
http_method = aws_api_gateway_method.misc_version_method.http_method
21+
status_code = 200
22+
response_models = {
23+
"application/json" = "Empty"
24+
}
25+
response_parameters = {
26+
"method.response.header.Access-Control-Allow-Origin" = true
27+
}
28+
depends_on = ["aws_api_gateway_method.misc_version_method"]
29+
}
30+
31+
resource "aws_api_gateway_integration" "misc_version_lambda_integration" {
32+
rest_api_id = data.aws_api_gateway_rest_api.rest_api.id
33+
resource_id = aws_api_gateway_resource.misc_version_resource.id
34+
http_method = aws_api_gateway_method.misc_version_method.http_method
35+
type = "AWS_PROXY"
36+
uri = aws_lambda_function.uds_api_1.invoke_arn
37+
integration_http_method = "POST"
38+
39+
# cache_key_parameters = ["method.request.path.proxy"]
40+
41+
timeout_milliseconds = 29000
42+
# request_parameters = {
43+
# "integration.request.path.proxy" = "method.request.path.proxy"
44+
# }
45+
}
46+
47+
##########################################################################################################################

tf-module/unity-cumulus/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ resource "aws_ssm_parameter" "health_check_value" {
182182
tier = "Advanced"
183183
value = jsonencode({
184184
healthCheckUrl = "${var.uds_base_url}/${var.dapa_api_prefix}/collections",
185-
landingPageUrl = "${var.unity_ui_base_url}/data/misc/stac_entry",
185+
landingPageUrl = "${var.unity_ui_base_url}/data/stac_browser/",
186186
componentName = "Data Catalog",
187187
})
188188
tags = var.tags

0 commit comments

Comments
 (0)