Skip to content

feat: Using Fastapi for all API endpoints #190

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 27 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
efe0ab1
fix: retry 5 times + wait 45 sec for DAAC
wphyojpl Jul 7, 2023
c39fde2
feat: make re-try configurable
wphyojpl Jul 7, 2023
4845f19
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Jul 10, 2023
bc8a922
feat: adding fastapi (in-progress)
wphyojpl Jul 20, 2023
bf37b6a
fix: get collection creation working (in-progress)
wphyojpl Jul 21, 2023
46a2f7b
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Jul 24, 2023
f803439
fix: add root link in collection stac
wphyojpl Jul 24, 2023
308d840
feat: updating terraform
wphyojpl Jul 24, 2023
74af0be
fix: actual creation has some error
wphyojpl Jul 25, 2023
774f3a8
fix: json to invoke magnum lambda is updated
wphyojpl Jul 25, 2023
b4d6948
chore: update log statement
wphyojpl Jul 26, 2023
3492b99
fix: attempting bugfix
wphyojpl Jul 26, 2023
2260947
fix: some weird error. updating function name to confirm it
wphyojpl Jul 26, 2023
a3217d4
fix: teraform error due to partial update only
wphyojpl Jul 26, 2023
3a297d8
fix: dummy commit
wphyojpl Jul 26, 2023
16bb957
fix: allow slash and no slash
wphyojpl Jul 26, 2023
72febf0
fix: trying slash and no-slash
wphyojpl Jul 31, 2023
64fb114
fix: trying slash and no-slash
wphyojpl Jul 31, 2023
c9454ad
fix: trying slash and no-slash
wphyojpl Jul 31, 2023
e57d88c
fix: trying slash and no-slash
wphyojpl Jul 31, 2023
b27be2a
fix: trying slash and no-slash
wphyojpl Jul 31, 2023
bb029c6
fix: trying slash and no-slash
wphyojpl Jul 31, 2023
30d7133
fix: trying slash and no-slash
wphyojpl Jul 31, 2023
cb13811
fix: trying slash and no-slash
wphyojpl Jul 31, 2023
64885de
fix: trying slash and no-slash
wphyojpl Jul 31, 2023
68f5ff3
feat: add uds endpoint tests
wphyojpl Jul 31, 2023
3fa9081
feat: am-uds-dapa comes from config with defaulted to that string
wphyojpl Jul 31, 2023
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Questions about our project? Please see our: [FAQ]([INSERT LINK TO FAQ / DISCUSS

<!-- example FAQ inline format>
1. Question 1
- Answer to question 1
- Answer to question 1.
2. Question 2
- Answer to question 2
-->
Expand Down
4 changes: 4 additions & 0 deletions ci.cd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ update_lambda_function_mcp_dev_6:
update_lambda_function_mcp_dev_7:
aws lambda update-function-code --s3-key unity_cumulus_lambda/cumulus_lambda_functions_deployment.zip --s3-bucket uds-dev-cumulus-public --function-name arn:aws:lambda:us-west-2:237868187491:function:uds-dev-cumulus-metadata_stac_generate_cmr --publish &>/dev/null

update_lambda_function_mcp_dev_uds_api:
aws lambda update-function-code --s3-key unity_cumulus_lambda/cumulus_lambda_functions_deployment.zip --s3-bucket uds-dev-cumulus-public --function-name arn:aws:lambda:us-west-2:237868187491:function:uds-dev-cumulus-uds_api_1 --publish &>/dev/null

mcp_dev_fastapi: upload_lambda_mcp_dev update_lambda_function_mcp_dev_uds_api
mcp_dev: upload_lambda_mcp_dev update_lambda_function_mcp_dev_1 update_lambda_function_mcp_dev_2 update_lambda_function_mcp_dev_4 update_lambda_function_mcp_dev_5


Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class CumulusCreateCollectionDapa:
def __init__(self, event):
print(event)
required_env = ['CUMULUS_LAMBDA_PREFIX', 'CUMULUS_WORKFLOW_SQS_URL']
if not all([k in os.environ for k in required_env]):
raise EnvironmentError(f'one or more missing env: {required_env}')
Expand Down
16 changes: 0 additions & 16 deletions cumulus_lambda_functions/cumulus_dapa/__init__.py

This file was deleted.

42 changes: 0 additions & 42 deletions cumulus_lambda_functions/cumulus_dapa/__main__.py

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

23 changes: 0 additions & 23 deletions cumulus_lambda_functions/cumulus_dapa/v1/__init__.py

This file was deleted.

This file was deleted.

72 changes: 0 additions & 72 deletions cumulus_lambda_functions/cumulus_dapa/v1/granules.py

This file was deleted.

9 changes: 6 additions & 3 deletions cumulus_lambda_functions/cumulus_dapa_client/dapa_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from cumulus_lambda_functions.lib.cognito_login.cognito_token_retriever import CognitoTokenRetriever
from cumulus_lambda_functions.lib.constants import Constants
from cumulus_lambda_functions.uds_api.web_service_constants import WebServiceConstants

LOGGER = logging.getLogger(__name__)

Expand All @@ -17,6 +18,7 @@ def __init__(self):
self.__dapa_base_api = None
self.__get_dapa_base_api()
self.__verify_ssl = True
self.__api_base_prefix = WebServiceConstants.API_PREFIX

def with_verify_ssl(self, verify_ssl: bool):
self.__verify_ssl = verify_ssl
Expand All @@ -27,6 +29,7 @@ def __get_dapa_base_api(self):
raise ValueError(f'missing key: {Constants.DAPA_API_KEY}')
self.__dapa_base_api = os.environ.get(Constants.DAPA_API_KEY)
self.__dapa_base_api = self.__dapa_base_api[:-1] if self.__dapa_base_api.endswith('/') else self.__dapa_base_api
self.__api_base_prefix = os.environ.get(Constants.DAPA_API_PREIFX_KEY) if Constants.DAPA_API_PREIFX_KEY in os.environ else self.__api_base_prefix
return self

def __get_token(self):
Expand All @@ -46,7 +49,7 @@ def get_collection(self, collection_id: str):
LOGGER.debug(f'getting collection details for: {collection_id}')
self.__get_token()
header = {'Authorization': f'Bearer {self.__token}'}
dapa_collection_url = f'{self.__dapa_base_api}/am-uds-dapa/collections?limit=1000'
dapa_collection_url = f'{self.__dapa_base_api}/{self.__api_base_prefix}/collections?limit=1000'
response = requests.get(url=dapa_collection_url, headers=header, verify=self.__verify_ssl)
if response.status_code > 400:
raise RuntimeError(
Expand Down Expand Up @@ -92,7 +95,7 @@ def get_granules(self, collection_id='*', limit=1000, offset=0, date_from='', da
:param date_to:
:return:
"""
dapa_granules_api = f'{self.__dapa_base_api}/am-uds-dapa/collections/{collection_id}/items?limit={limit}&offset={offset}'
dapa_granules_api = f'{self.__dapa_base_api}/{self.__api_base_prefix}/collections/{collection_id}/items?limit={limit}&offset={offset}'
if date_from != '' or date_to != '':
dapa_granules_api = f"{dapa_granules_api}&datetime={date_from if date_from != '' else '..'}/{date_to if date_to != '' else '..'}"
if filter is not None:
Expand All @@ -111,7 +114,7 @@ def get_granules(self, collection_id='*', limit=1000, offset=0, date_from='', da
return granules_result

def ingest_granules_w_cnm(self, cnm_ingest_body: dict) -> str:
dapa_ingest_cnm_api = f'{self.__dapa_base_api}/am-uds-dapa/collections/'
dapa_ingest_cnm_api = f'{self.__dapa_base_api}/{self.__api_base_prefix}/collections/'
LOGGER.debug(f'getting granules for: {dapa_ingest_cnm_api}')
self.__get_token()
header = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,4 @@ def start(self):
)
stac_collection.add_links(self.__files)
new_collection = stac_collection.to_dict(include_self_link=False)
if 'links' in new_collection and len(new_collection['links']) > 0 and new_collection['links'][0]['rel'] == 'root':
new_collection['links'][0]['href'] = './collection.json'
return new_collection
1 change: 1 addition & 0 deletions cumulus_lambda_functions/lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ class Constants:
BASE64_STR = 'BASE64'
PARAM_STORE = 'PARAM_STORE'
DAPA_API_KEY = 'DAPA_API'
DAPA_API_PREIFX_KEY = 'DAPA_API_PREIFX_KEY'
Loading