Skip to content
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

Update endpoints to DNS names, made "ops" the default unity environment. #26

Merged
merged 7 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions .github/workflows/unity-py-python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ name: Unity-sds-client Python Build
# Run on an PR if it includes unity-py changes OR if the schema in health are changed.
on:
push:
branches:
branches:
- main
paths:
paths:
- 'libs/unity-py/**'
pull_request:
branches:
branches:
- main
paths:
- 'libs/unity-py/**'
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
src:
- 'libs/unity-py/**'
- name: Software Version Check
if: steps.filter.outputs.src == 'true'
if: steps.changes.outputs.src == 'true'
run: |
unity_py_proposed_version=`poetry version -s`
echo "curl -s -o /dev/null -w \"%{http_code}\" https://pypi.org/project/unity-sds-client/$unity_py_proposed_version/"
Expand Down Expand Up @@ -79,12 +79,12 @@ jobs:
UNITY_USER: '${{ secrets.UNITY_TEST_USER }}'
UNITY_PASSWORD: '${{ secrets.UNITY_TEST_PASSWORD }}'
run: |
poetry run pytest --cov-report=lcov --cov=unity_sds_client -o log_cli=true --log-cli-level=DEBUG
poetry run pytest --cov-report=lcov --cov=unity_sds_client -o log_cli=true --log-cli-level=DEBUG
- name: Coveralls
uses: coverallsapp/[email protected]
version:
needs: build
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -99,12 +99,12 @@ jobs:
uses: abatilo/[email protected]
with:
poetry-version: "1.5.1"
# Commented out the version bump code. Will publish new unity-py version to pypi on push to main.
# Commented out the version bump code. Will publish new unity-py version to pypi on push to main.
# This means we are always releasing. This will fail if the version already exists in Pypi.
# We must ensure that the version has been updated.
# ADded version check above.
# Future work: set PR test to ensure the version has been updated.

# - name: version-bump
# run: |
# poetry version prerelease
Expand Down
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ repos:
hooks:
- id: ruff

# unity-py bandit config
- repo: https://github.com/PyCQA/bandit
rev: "1.7.8" # you must change this to newest version
hooks:
- id: bandit
files: '^libs/unity-py/.*\.py'
args:
[
"--configfile=pyproject.toml",
"--configfile=libs/unity-py/pyproject.toml",
"--severity-level=high",
"--confidence-level=high",
]
Expand Down
10 changes: 10 additions & 0 deletions libs/unity-py/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.0] - 2024-07-31
### Added
### Fixed
* cleaned up some README formatting
### Changed
* changed endpoints from cloudfront urls to DNS entries
### Removed
### Security
### Deprecated


## [0.5.0] - 2024-07-23

Expand Down
2 changes: 1 addition & 1 deletion libs/unity-py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "unity-sds-client"
version = "0.5.0"
version = "0.5.1"
description = "Unity-Py is a Python client to simplify interactions with NASA's Unity Platform."
authors = ["Anil Natha, Mike Gangl"]
readme = "README.md"
Expand Down
15 changes: 3 additions & 12 deletions libs/unity-py/unity_sds_client/envs/environments.cfg
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
[DEV]
client_id = 40c2s0ulbhp9i0fmaph3su9jch
auth_endpoint = https://cognito-idp.us-west-2.amazonaws.com
unity_href = https://d3vc8w9zcq658.cloudfront.net/
unity_href = https://api.dev.mdps.mcp.nasa.gov/

[TEST]
client_id = 71894molftjtie4dvvkbjeard0
auth_endpoint = https://cognito-idp.us-west-2.amazonaws.com
unity_href = https://dxebrgu0bc9w7.cloudfront.net/
unity_href = https://api.test.mdps.mcp.nasa.gov/

[PROD]
client_id = 7vehllplbone6p4usqgutqun35
auth_endpoint = https://cognito-idp.us-west-2.amazonaws.com
unity_href = https://d2zjsabg0fonik.cloudfront.net/

;[APPLICATIONS]
;
;
;[DATA]
;dapa_endpoint = https://58nbcawrvb.execute-api.us-west-2.amazonaws.com/test/
;
;[SPS]
;sps_endpoint = http://a22b9d7b66df24e6fb3326ecd4cb0614-676486270.us-west-2.elb.amazonaws.com:5001/
unity_href = https://api.mdps.mcp.nasa.gov/
40 changes: 26 additions & 14 deletions libs/unity-py/unity_sds_client/unity.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
from configparser import ConfigParser, ExtendedInterpolation

from unity_sds_client.services.data_service import DataService
from unity_sds_client.services.process_service import ProcessService
from unity_sds_client.services.health_service import HealthService
from unity_sds_client.unity_session import UnitySession
from unity_sds_client.unity_exception import UnityException
from unity_sds_client.services.process_service import ProcessService
from unity_sds_client.unity_environments import UnityEnvironments
from unity_sds_client.unity_exception import UnityException
from unity_sds_client.unity_services import UnityServices
from unity_sds_client.unity_session import UnitySession


class Unity(object):
Expand All @@ -16,24 +17,30 @@ class Unity(object):
is passed to different services and resources as needed.
"""

def __init__(self, environment: UnityEnvironments = UnityEnvironments.TEST, config_file_override:str = None):
def __init__(
self,
environment: UnityEnvironments = UnityEnvironments.PROD,
config_file_override: str = None,
):
"""
:param environment: the default environment for a session to work with. Defaults to 'TEST' unity environment.
:param environment: the default environment for a session to work with. Defaults to 'PROD' unity environment.
:param config_file_override: absolute path to a config file containing settings to override default config
"""
env = environment
config = _read_config([
os.path.dirname(os.path.realpath(__file__)) + "/envs/environments.cfg".format(str(env.value).lower()),
config_file_override
])
config = _read_config(
[
os.path.dirname(os.path.realpath(__file__)) + "/envs/environments.cfg",
config_file_override,
]
)
self._session = UnitySession(env.value, config)

def set_project(self, project):
"""
:param project: the project to use when interacting with venue specific services. Used in building the restful
endpoint.
"""
self._session._project = project
self._session._project = project

def set_venue(self, venue):
"""
Expand Down Expand Up @@ -66,15 +73,20 @@ def client(self, service_name: UnityServices):
def __str__(self):
response = "\nUNITY CONFIGURATION"
response = response + "\n" + len(response) * "-" + "\n"

config = self._session.get_config()
config_sections = config.sections()
for section in config_sections:
response = response + "\n[{}]\n".format(section)
for setting in dict(config[section]):
response = response + "{}: {}\n".format(setting, dict(config[section])[setting])

response = response + self.client(UnityServices.HEALTH_SERVICE).generate_health_status_report()
response = response + "{}: {}\n".format(
setting, dict(config[section])[setting]
)

response = (
response
+ self.client(UnityServices.HEALTH_SERVICE).generate_health_status_report()
)

return response

Expand Down
Loading