Skip to content

Commit

Permalink
Merge pull request #2010 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Release v5.0.1
  • Loading branch information
jtherrmann authored Jan 12, 2024
2 parents 9c36511 + 731c1ec commit 67e07ba
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 71 deletions.
2 changes: 0 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ updates:
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "openapi-spec-validator"
labels:
- "bumpless"
- package-ecosystem: "github-actions"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ on:

jobs:
call-changelog-check-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.8.3
uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.9.0
secrets:
USER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/create-jira-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
call-create-jira-issue-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.8.3
uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.9.0
secrets:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-daac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ jobs:
call-bump-version-workflow:
if: github.ref == 'refs/heads/main'
needs: deploy
uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.8.3
uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.9.0
secrets:
USER_TOKEN: ${{ secrets.TOOLS_BOT_PAK }}
2 changes: 1 addition & 1 deletion .github/workflows/labeled-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ on:

jobs:
call-labeled-pr-check-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.8.3
uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.9.0
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
call-release-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.8.3
uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.9.0
with:
release_prefix: HyP3
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ jobs:
snyk iac test --severity-threshold=high
call-secrets-analysis-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.8.3
uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.9.0
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ 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).

## [5.0.1]
### Fixed
- Upgrade the `openapi-core`, `openapi-spec-validator`, and `jsonschema` packages to their latest versions. This is now possible thanks to the pre-release of [openapi-core v0.19.0a1](https://github.com/python-openapi/openapi-core/releases/tag/0.19.0a1), which fixes <https://github.com/python-openapi/openapi-core/issues/662>. Resolves <https://github.com/ASFHyP3/hyp3/issues/1193>.

## [5.0.0]
### Removed
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/hyp3_api/api-spec/job_parameters.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ components:
enum:
- {{ job_type }}
name:
$ref: "./openapi-spec.yml#components/schemas/name"
$ref: "./openapi-spec.yml#/components/schemas/name"
job_parameters:
$ref: "#/components/schemas/{{ job_type }}Parameters"

Expand Down
17 changes: 12 additions & 5 deletions apps/api/src/hyp3_api/api-spec/openapi-spec.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ info:
security:
- EarthDataLogin: []

{% if security_environment == 'EDC' %}
# See https://github.com/ASFHyP3/hyp3/pull/2009 for context.
servers:
- url: /
- url: /api
{% endif %}

paths:

/jobs:
Expand Down Expand Up @@ -53,7 +60,7 @@ paths:
- name: job_type
in: query
schema:
$ref: "./job_parameters.yml#components/schemas/job_type"
$ref: "./job_parameters.yml#/components/schemas/job_type"
- name: start_token
in: query
schema:
Expand Down Expand Up @@ -138,7 +145,7 @@ components:
quota:
$ref: "#/components/schemas/quota"
job_names:
$ref: "#components/schemas/job_names_list"
$ref: "#/components/schemas/job_names_list"

quota:
description: Containes the limit of jobs per month and the amount remaining for a user.
Expand Down Expand Up @@ -168,7 +175,7 @@ components:
minItems: 1
maxItems: 200
items:
$ref: "./job_parameters.yml#components/schemas/new_job"
$ref: "./job_parameters.yml#/components/schemas/new_job"

list_of_jobs:
type: array
Expand Down Expand Up @@ -254,9 +261,9 @@ components:
user_id:
$ref: "#/components/schemas/user_id"
job_type:
$ref: "./job_parameters.yml#components/schemas/job_type"
$ref: "./job_parameters.yml#/components/schemas/job_type"
job_parameters:
$ref: "./job_parameters.yml#components/schemas/job_parameters"
$ref: "./job_parameters.yml#/components/schemas/job_parameters"
request_time:
$ref: "#/components/schemas/datetime"
status_code:
Expand Down
85 changes: 37 additions & 48 deletions apps/api/src/hyp3_api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
import yaml
from flask import abort, g, jsonify, make_response, redirect, render_template, request
from flask_cors import CORS
from openapi_core import OpenAPI
from openapi_core.contrib.flask.decorators import FlaskOpenAPIViewDecorator
from openapi_core.contrib.flask.handlers import FlaskOpenAPIErrorsHandler
from openapi_core.contrib.flask.views import FlaskOpenAPIView
from openapi_core.spec.shortcuts import create_spec
from openapi_core.validation.response.datatypes import ResponseValidationResult

from hyp3_api import app, auth, handlers
from hyp3_api.openapi import get_spec_yaml

api_spec_file = Path(__file__).parent / 'api-spec' / 'openapi-spec.yml'
api_spec_dict = get_spec_yaml(api_spec_file)
api_spec = create_spec(api_spec_dict)
api_spec = OpenAPI.from_dict(api_spec_dict)
CORS(app, origins=r'https?://([-\w]+\.)*asf\.alaska\.edu', supports_credentials=True)

AUTHENTICATED_ROUTES = ['/jobs', '/user']
Expand Down Expand Up @@ -68,7 +67,7 @@ def render_ui():


@app.errorhandler(404)
def error404(e):
def error404(_):
return handlers.problem_format(404, 'The requested URL was not found on the server.'
' If you entered the URL manually please check your spelling and try again.')

Expand All @@ -93,67 +92,57 @@ def default(self, o):
json.JSONEncoder.default(self, o)


class NonValidator:
def __init__(self, spec):
pass

def validate(self, res):
return ResponseValidationResult()


class ErrorHandler(FlaskOpenAPIErrorsHandler):
def __init__(self):
super().__init__()

@classmethod
def handle(cls, errors):
response = super().handle(errors)
def __call__(self, errors):
response = super().__call__(errors)
error = response.json['errors'][0]
return handlers.problem_format(error['status'], error['title'])


class Jobs(FlaskOpenAPIView):
def __init__(self, spec):
super().__init__(spec)
self.response_validator = NonValidator
self.openapi_errors_handler = ErrorHandler
app.json_encoder = CustomEncoder

openapi = FlaskOpenAPIViewDecorator(
api_spec,
response_cls=None,
errors_handler_cls=ErrorHandler,
)


def post(self):
return jsonify(handlers.post_jobs(request.get_json(), g.user))
@app.route('/jobs', methods=['POST'])
@openapi
def jobs_post():
return jsonify(handlers.post_jobs(request.get_json(), g.user))

def get(self, job_id):
if job_id is not None:
return jsonify(handlers.get_job_by_id(job_id))
parameters = request.openapi.parameters.query
start = parameters.get('start')
end = parameters.get('end')
return jsonify(handlers.get_jobs(

@app.route('/jobs', methods=['GET'])
@openapi
def jobs_get():
parameters = request.openapi.parameters.query
start = parameters.get('start')
end = parameters.get('end')
return jsonify(
handlers.get_jobs(
parameters.get('user_id') or g.user,
start.isoformat(timespec='seconds') if start else None,
end.isoformat(timespec='seconds') if end else None,
parameters.get('status_code'),
parameters.get('name'),
parameters.get('job_type'),
parameters.get('start_token'),
))


class User(FlaskOpenAPIView):
def __init__(self, spec):
super().__init__(spec)
self.response_validator = NonValidator
self.openapi_errors_handler = ErrorHandler
)
)

def get(self):
return jsonify(handlers.get_user(g.user))

@app.route('/jobs/<job_id>', methods=['GET'])
@openapi
def jobs_get_by_job_id(job_id):
return jsonify(handlers.get_job_by_id(job_id))

app.json_encoder = CustomEncoder

jobs_view = Jobs.as_view('jobs', api_spec)
app.add_url_rule('/jobs', view_func=jobs_view, methods=['GET'], defaults={'job_id': None})
app.add_url_rule('/jobs', view_func=jobs_view, methods=['POST'])
app.add_url_rule('/jobs/<job_id>', view_func=jobs_view, methods=['GET'])

user_view = User.as_view('user', api_spec)
app.add_url_rule('/user', view_func=user_view)
@app.route('/user', methods=['GET'])
@openapi
def user_get():
return jsonify(handlers.get_user(g.user))
8 changes: 4 additions & 4 deletions requirements-all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
-r requirements-apps-start-execution-worker.txt
-r requirements-apps-disable-private-dns.txt
-r requirements-apps-update-db.txt
boto3==1.34.9
boto3==1.34.13
jinja2==3.1.2
moto[dynamodb]==4.2.12
pytest==7.4.3
pytest==7.4.4
PyYAML==6.0.1
responses==0.24.1
flake8==6.1.0
flake8-import-order==0.18.2
flake8-blind-except==0.2.1
flake8-builtins==2.2.0
setuptools==69.0.2
openapi-spec-validator==0.4.0
setuptools==69.0.3
openapi-spec-validator==0.7.1
cfn-lint==0.83.7
5 changes: 3 additions & 2 deletions requirements-apps-api.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
flask==2.2.5
Flask-Cors==4.0.0
jsonschema==4.17.3
openapi-core==0.14.5
jsonschema==4.20.0
# TODO convert this pin back to the normal format after the next PyPI release
openapi-core @ git+https://github.com/python-openapi/[email protected]
prance==23.6.21.0
PyJWT==2.8.0
requests==2.31.0
Expand Down
2 changes: 1 addition & 1 deletion requirements-apps-disable-private-dns.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
boto3==1.34.9
boto3==1.34.13
2 changes: 1 addition & 1 deletion requirements-apps-start-execution-manager.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
boto3==1.34.9
boto3==1.34.13
./lib/dynamo/
./lib/lambda_logging/
2 changes: 1 addition & 1 deletion requirements-apps-start-execution-worker.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
boto3==1.34.9
boto3==1.34.13
./lib/lambda_logging/

0 comments on commit 67e07ba

Please sign in to comment.