Skip to content

[33] scheduled build #34

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

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d1ae3a2
update black;
chrisbc May 29, 2024
b4112ba
add about + versino resolvers; tweak flake8 settings
chrisbc May 30, 2024
fed74ad
update changelog;
chrisbc May 30, 2024
e28ce68
add GHA scripts;
chrisbc May 30, 2024
97f9538
setup poretry group `dev` & remove extras;
chrisbc May 30, 2024
2188a67
added model & node resolvers;
chrisbc May 30, 2024
d14dbeb
new SLT models
chrisbc May 30, 2024
c6d5ec0
add tag attribute on SourceLogicTreeBranch;
chrisbc May 30, 2024
4272e48
add branch_set_short_name
chrisbc May 30, 2024
de8d6bc
add relay node resolvers for all model classes;
chrisbc May 30, 2024
f5584c2
refactor slt schemas into module; more coverage for as_node tests;
chrisbc May 31, 2024
86a8266
add BranchInversionSource class
chrisbc May 31, 2024
086a611
configure api and wsgi entry point
chrisbc Jun 3, 2024
2ae2c2f
rename tests for more clarity;
chrisbc Jun 3, 2024
2239198
add inversion_id property
chrisbc Jun 3, 2024
a88db26
add lru_cache to improve API performance
chrisbc Jun 3, 2024
b33c816
add BranchDistributedSource; remove Node suppurt from source classes;…
chrisbc Jun 3, 2024
80f2b8d
added current_model_version resolver; get_model resolver support defa…
chrisbc Jun 4, 2024
08072c9
GHA deployment tweaks
chrisbc Jun 4, 2024
2604a0b
reorg tests; kill commented code blocks; detox;
chrisbc Jun 4, 2024
21abe66
Merge pull request #20 from GNS-Science/feature/api_based_on_nzshm-model
chrisbc Jun 4, 2024
ad4eeae
revert to secrets for GHA;
chrisbc Jun 4, 2024
60c1e62
change temp api key name;
chrisbc Jun 4, 2024
af4019d
fix serverless deployment config;
chrisbc Jun 4, 2024
a380b7a
use dockerizePip to ensure AWS linuxB compatability (ref GLIBC 2.28 n…
chrisbc Jun 5, 2024
cc60461
update from flask-graphql to graphql-server; version updates;
chrisbc Jun 5, 2024
e76529d
update from flask-graphql to graphql-server;
chrisbc Jun 5, 2024
6a5c629
serverless version updates;
chrisbc Jun 5, 2024
1afb5f8
added fix/test for missing model title;
chrisbc Jun 5, 2024
ad97850
Merge pull request #23 from GNS-Science/fix/model_title_missing
chrisbc Jun 5, 2024
e664ba6
new gmm classes & tests; WIP util LIB is updated;
chrisbc Jun 6, 2024
cdc088f
update nzshm-model; use branch_set short_name for GMM node identity r…
chrisbc Jun 7, 2024
7b65d8d
fix branch_set_short_name attrinute and tests
chrisbc Jun 7, 2024
7c12901
Merge pull request #25 from GNS-Science/feature/24_gmm_logic_tree_cla…
chrisbc Jun 9, 2024
e4fb8d9
[29] use reusable workflow for testing (#31)
voj Apr 28, 2025
6a560ac
WIP
voj May 6, 2025
b0a6f9a
tidy
voj May 6, 2025
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
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
* kororaa-graphql-api version:
* Python version:
* Operating System:

### Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

### What I Did

```
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
```
75 changes: 75 additions & 0 deletions .github/workflows/deploy-to-aws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: deploy-aws-lambda

on:
push:
branches:
- deploy-test
- main

jobs:
call-test-workflow:
uses: GNS-Science/nshm-github-actions/.github/workflows/python-run-tests.yml@main
with:
operating-systems: "['ubuntu-latest']"
python-versions: "['3.10']"
secrets: inherit

deploy:
needs: call-test-workflow
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
python-version: ['3.10']

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install and configure Poetry
uses: GNS-Science/install-poetry@main
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
check-latest: true

- name: upgrade NPM
run: npm install --location=global npm@latest

# - name: Verify NPM
# run: npm doctor

- name: Install Dependencies
run: npm install

- name: List packages
run: npm ls

- name: Serverless Doctor
run: npm run-script sls_doctor

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-southeast-2

- name: Serverless Deploy ....
env:
ENABLE_METRICS: 0
run: |
if [[ "${{github.base_ref}}" == "main" || "${{github.ref}}" == 'refs/heads/main' ]]; then
STAGE=prod npm run-script deploy
else
STAGE=test npm run-script deploy
fi

19 changes: 19 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Dev workflow

on:
schedule:
- cron: '25 5 * * 0' # At 05:25 on Sunday
pull_request:
branches: [main, deploy-test]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
call-test-workflow:
uses: GNS-Science/nshm-github-actions/.github/workflows/python-run-tests.yml@main
with:
operating-systems: "['ubuntu-latest']"
python-versions: "['3.10']"
delete-poetry-lock: ${{ github.event_name == 'schedule' }} # the scheduled build tests against newer dependencies
secrets: inherit
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Publish package on main branch if it's tagged with 'v*'

name: release & publish workflow

# Controls when the action will run.
on:
# Triggers the workflow on push events but only for the master branch
push:
tags:
- 'v*'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "release"
release:
name: Create Release
runs-on: ubuntu-20.04

strategy:
matrix:
python-versions: [3.8]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Get version from tag
id: tag_name
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
shell: bash

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_depth: 10
version: ${{ steps.tag_name.outputs.current_version }}
path: ./CHANGELOG.md

- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-versions }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry

- name: build documentation
run: |
poetry install -E doc
poetry run mkdocs build

- name: publish documentation
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site

# - name: Build wheels and source tarball
# run: >-
# poetry build

# - name: show temporary files
# run: >-
# ls -l

# - name: create github release
# id: create_release
# uses: softprops/action-gh-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# body: ${{ steps.changelog_reader.outputs.changes }}
# files: dist/*.whl
# draft: false
# prerelease: false

# - name: publish to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
# skip_existing: true
16 changes: 13 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
# Changelog


## [0.2.0] 2024-05-30
## [0.2.0] - 2024-06-07
### Changed
- Complete reset, no more django
- all previous code is mothballed
- flake8 config
- new about and version resolvers

### Added
- Node resolver support for NshmModel
- get_model resolver
- get_models resolver
- source logic tree models and resolvers
- gmmm logic tree models and resolvers

## [0.1.3] - 2023-09-04
## Added
### Added
- new about and version resolvers

## [0.1.2] - 2023-09-04
## Changed
### Changed
- configure static_url correctly for both local & AWS

## [0.1.1] - 2023-09-01
Expand Down
65 changes: 65 additions & 0 deletions nshm_model_graphql_api/nshm_model_graphql_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""Main module."""

import logging
import logging.config
import os

import yaml
from flask import Flask
from flask_cors import CORS
from graphql_server.flask import GraphQLView

# from nshm_model_graphql_api.library_version_check import log_library_info
from nshm_model_graphql_api.schema import schema_root

LOGGING_CFG = os.getenv("LOGGING_CFG", "nshm_model_graphql_api/logging_aws.yaml")
logger = logging.getLogger(__name__)

# TESTING = os.getenv('TESTING', False)
# if not TESTING:
# # because in testing, this screws up moto mocking
# log_library_info(['botocore', 'boto3', 'fiona'])


def create_app():
"""Function that creates our Flask application."""
app = Flask(__name__)
CORS(app)

# app.before_first_request(migrate)

app.add_url_rule(
"/graphql",
view_func=GraphQLView.as_view(
"graphql",
schema=schema_root,
graphiql=True,
),
)

"""
Setup logging configuration
ref https://fangpenlin.com/posts/2012/08/26/good-logging-practice-in-python/
"""
if os.path.exists(LOGGING_CFG):
with open(LOGGING_CFG, "rt") as f:
config = yaml.safe_load(f.read())
logging.config.dictConfig(config)
else:
print("Warning, no logging config found, using basicConfig(INFO)")
logging.basicConfig(level=logging.INFO)

logger.debug("DEBUG logging enabled")
logger.info("INFO logging enabled")
logger.warning("WARN logging enabled")
logger.error("ERROR logging enabled")

return app


# pragma: no cover
app = create_app()


if __name__ == "__main__":
app.run()
3 changes: 3 additions & 0 deletions nshm_model_graphql_api/schema/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""API schema package."""

from .schema_root import schema_root # noqa: F401
Loading