Skip to content

Commit

Permalink
Release/4.2.0 (#150)
Browse files Browse the repository at this point in the history
* Add support for DPS sandbox queue  (#136)

* Respond with HTTP 400 if invalid queue provided during registration

* Update dos job time limits if using dps sand box queue

* Ensure that message is of type string

* update code to use new job_queue.get_user_queues() function

* Move queue settings to db

* add is_default and time_limit_minutes to job_queue endpoints

* Job submission bug fix

---------

Co-authored-by: bsatoriu <[email protected]>

* /version 4.1.0a8

* /version 4.2.0a0

* /version 4.1.0rc1

* Mount maap-dps env file to read api host and dps token from the host (#139)

* /version 4.1.0rc2

* Set job time limit based on the queue time limits if specified (#140)

* /version 4.1.0rc3

* Convert time from minutes to seconds (#141)

* /version 4.1.0rc4

* Add orgs to user profile

* /version 4.1.0rc5

* Update SQLALCHEMY_ENGINE_OPTIONS settings

* /version 4.1.0rc6

* /version 4.1.0

* /version 4.1.1a0

* Bug/edc credentials null error  (#144)

* Fix edcCredentials null reference bug

* Update api/endpoints/members.py

Co-authored-by: Chuck Daniels <[email protected]>

---------

Co-authored-by: bsatoriu <[email protected]>
Co-authored-by: Chuck Daniels <[email protected]>

* /version 4.1.1a1

* Bug/user bucket inline policy (1126) (#145)

* expand inline folder policy to support reading/writing

* Update members.py

---------

Co-authored-by: bsatoriu <[email protected]>

* /version 4.1.1a2

* Remove need environmentsjson (#147)

* rewrote get_config function to match jupyter server extension

* added additional print statements

* added more print statements

* printing all environment variables

* reverted to the correct function and added back environment to settings.py

* added more print statements

* changed the backup environments.json filepath

* now reading from environments.json in MAAP API

* updated import for environments.json

* corrected to json.load

* removed print statements

* added error handling

* purposely added error

* corrected mistake

* changed to FileNotFoundError to be more descriptive to pass test

* /version 4.1.1a3

* Change log update 420 (#149)

* updated changelog

* fixed version in changelog

* /version 4.1.1a4

* Fix bug by checking out develop

Bug was causing the version bump to happen on the newly created branch instead of on develop

* /version 4.2.0rc1

---------

Co-authored-by: Sujen Shah <[email protected]>
Co-authored-by: bsatoriu <[email protected]>
Co-authored-by: bsatoriu <[email protected]>
Co-authored-by: bsatoriu <[email protected]>
Co-authored-by: Chuck Daniels <[email protected]>
Co-authored-by: grallewellyn <[email protected]>
Co-authored-by: Frank Greguska <[email protected]>
Co-authored-by: frankinspace <[email protected]>
  • Loading branch information
9 people authored Feb 26, 2025
1 parent 3463b11 commit 68cbe45
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v4.2.0] - 2025-02-19
- [pull/147](https://github.com/MAAP-Project/maap-api-nasa/pull/147) - Removed the need for tracking environments.json

## [v4.1.0] - 2024-09-10
- [pull/131](https://github.com/MAAP-Project/maap-api-nasa/pull/131) - Added query params to job list endpoint
- [pull/135](https://github.com/MAAP-Project/maap-api-nasa/pull/135) - User secret management
Expand Down
18 changes: 10 additions & 8 deletions api/endpoints/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
from api import settings
import requests
import urllib.parse
import json
import os

log = logging.getLogger(__name__)

ns = api.namespace('environment', description='Operations related to the MAAP environment')


@ns.route('/config')
class Config(Resource):
def get(self):
Expand Down Expand Up @@ -58,16 +59,17 @@ def get(self, ade_host):


def get_config(ade_host):
req = requests.get(settings.MAAP_ENVIRONMENT_FILE)
if req.status_code == requests.codes.ok:
data = req.json()
else:
print('Content was not found.')
try:
ROOT = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(ROOT, "environments.json")) as f:
data = json.load(f)
except FileNotFoundError:
msg = "environments.json file could not be found"
logging.exception(msg)
raise FileNotFoundError(msg)

base_url = "{0.netloc}".format(urlsplit(urllib.parse.unquote(ade_host)))

match = next((x for x in data if base_url in x['ade_server']), None)
maap_config = next((x for x in data if x['default_host'] == True), None) if match is None else match

return maap_config

33 changes: 33 additions & 0 deletions api/endpoints/environments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
"environment": "dit",
"ade_server": "ade.dit.maap-project.org",
"api_server": "api.dit.maap-project.org",
"auth_server": "auth.dit.maap-project.org",
"mas_server": "repo.dit.maap-project.org",
"edsc_server": "ade.dit.maap-project.org:30052",
"workspace_bucket": "maap-dit-workspace",
"kibana_url": "https://35.88.169.231/metrics/goto/4f1115df1b6563782292fb1f75676f95",
"default_host": true
},
{
"environment": "uat",
"ade_server": "ade.uat.maap-project.org",
"api_server": "api.uat.maap-project.org",
"auth_server": "auth.uat.maap-project.org",
"mas_server": "repo.uat.maap-project.org",
"edsc_server": "ade.uat.maap-project.org:30052",
"workspace_bucket": "maap-uat-workspace",
"default_host": false
},
{
"environment": "ops",
"ade_server": "ade.maap-project.org",
"api_server": "api.maap-project.org",
"auth_server": "auth.maap-project.org",
"mas_server": "mas.maap-project.org",
"edsc_server": "ade.maap-project.org:30052",
"workspace_bucket": "maap-ops-workspace",
"default_host": false
}
]
38 changes: 20 additions & 18 deletions api/endpoints/members.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,26 +643,18 @@ def get(self, endpoint_uri):
if maap_user is None:
return Response('Unauthorized', status=status.HTTP_401_UNAUTHORIZED)
else:
edc_response = get_edc_credentials(endpoint_uri=endpoint_uri, user_id=maap_user.id)
json_response = get_edc_credentials(endpoint_uri=endpoint_uri, user_id=maap_user.id)

try:
edc_response_json = json.loads(edc_response)
response = jsonify(
accessKeyId=edc_response_json['accessKeyId'],
secretAccessKey=edc_response_json['secretAccessKey'],
sessionToken=edc_response_json['sessionToken'],
expiration=edc_response_json['expiration']
)
response = jsonify(
accessKeyId=json_response['accessKeyId'],
secretAccessKey=json_response['secretAccessKey'],
sessionToken=json_response['sessionToken'],
expiration=json_response['expiration']
)

response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Origin', '*')

return response

except ValueError as ex:
response_body = dict()
response_body["code"] = status.HTTP_500_INTERNAL_SERVER_ERROR
response_body["message"] = edc_response.decode("utf-8")
return response_body, status.HTTP_500_INTERNAL_SERVER_ERROR
return response


@ns.route('/self/awsAccess/workspaceBucket')
Expand Down Expand Up @@ -699,6 +691,16 @@ def get(self):
"s3:ListMultipartUploadParts",
"s3:AbortMultipartUpload"
],
"Resource": [
"arn:aws:s3:::{settings.WORKSPACE_BUCKET}/{maap_user.username}/*"
]
}},
{{
"Sid": "GrantListAccess",
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": "arn:aws:s3:::{settings.WORKSPACE_BUCKET}",
"Condition": {{
"StringLike": {{
Expand Down Expand Up @@ -793,4 +795,4 @@ def get_edc_credentials(endpoint_uri, user_id):
else:
edl_response = edl_federated_request(url=endpoint)

return edl_response.content
return edl_response.json()
2 changes: 0 additions & 2 deletions api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def str2bool(v):
GITLAB_TOKEN = os.getenv('GITLAB_TOKEN', 'foobar')
GITLAB_API_TOKEN = os.getenv('GITLAB_API_TOKEN','') # New setting inherited from sister, remove comment after API is stable

MAAP_ENVIRONMENT_FILE = os.getenv('MAAP_ENVIRONMENT_FILE', 'https://raw.githubusercontent.com/MAAP-Project/maap-jupyter-ide/develop/maap_environments.json')

REPO_NAME = os.getenv('REPO_NAME', 'register-job')
REPO_PATH = os.getenv('REPO_PATH', '/home/ubuntu/repo')
VERSION = os.getenv('VERSION', 'master')
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "maap-api-nasa"
version = "4.1.0"
version = "4.2.0rc1"
description = "NASA Python implementation of the MAAP API specification"
authors = ["MAAP-Project Platform <[email protected]>"]
license = "Apache 2.0"
Expand Down

0 comments on commit 68cbe45

Please sign in to comment.