Skip to content
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.2
current_version = 0.2.3
commit = True
tag = False

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-to-aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ jobs:
python-version: '3.12'
node-version: '22'
docker: true
node-pkg-manager: 'yarn2'
secrets: inherit
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Changelog

## [0.2.3] - PENDING
## [0.2.3] - 2025-09-23

### Changed
- pinned import on graphql_server library to 3.0.0b7 until upstream release is fixed.
- upgraded to Python 3.12
- move to yarn2 for node package management
- update python packages with security warnings

## [0.2.2] - 2025-07-23

Expand Down
26 changes: 14 additions & 12 deletions Containerise-00.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,35 @@ Login Succeeded

## Get a base image

Using the AWS official python lambda image: `public.ecr.aws/lambda/python:3.11`
Using the AWS official python lambda image: `public.ecr.aws/lambda/python:3.12`

```
docker pull public.ecr.aws/lambda/python:3.11
docker pull public.ecr.aws/lambda/python:3.12
3.12: Pulling from lambda/python
.....
Status: Downloaded newer image for public.ecr.aws/lambda/python:3.11
public.ecr.aws/lambda/python:3.11
Status: Downloaded newer image for public.ecr.aws/lambda/python:3.12
public.ecr.aws/lambda/python:3.12
```

### get the requirements
poetry export --without-hashes --format=requirements.txt > requirements.txt

### test wsgi handlers

`poetry run npx serverless wsgi serve`
```
ENABLE_METRICS=0 poetry run yarn sls wsgi serve
```

## A Dockerfile

see [Dockerfile](./Dockerfile)

### build it
```
BUILDX_NO_DEFAULT_ATTESTATIONS=1 yarn sls package
```

`BUILDX_NO_DEFAULT_ATTESTATIONS=1 npx serverless package`

### and/or deploy it

this will push the image

`BUILDX_NO_DEFAULT_ATTESTATIONS=1 npx serverless deploy --stage dev --region us-east-1`
### and/or just deploy it
```
BUILDX_NO_DEFAULT_ATTESTATIONS=1 yarn sls deploy --stage dev --region ap-southeast-2
```
39 changes: 22 additions & 17 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
# DEVELOPMENT

This application uses serverless.com.

This application uses serverless.com.

### Environment setup

- clone the repo
- check/install a recent node version >=17.8
- check/install a recent npm version >=8.11
- install serverless `npm install --save serverless` [more info]()
- install `npm install --save serverless-python-requirements` [more info](https://www.serverless.com/blog/serverless-python-packaging/)
- install `npm install -save serverless-wsgi` [more info](https://www.serverless.com/plugins/serverless-wsgi)
- `serverless plugin install -n serverless-python-requirements`
- `serverless plugin install -n serverless-wsgi`
- check/install a recent node version >=22
`nvm use 22`

- setup python env
```
pyenv local 3.12
poetry env use 3.12
```

setup yarn 2 ...
```
corepack enable
yarn set version berry
yarn install
```

Now `sls info` should print something like ...
Now `yarn sls info` should print something like ...

```
chrisbc@tryharder-ubuntu:/GNSDATA/API/kororaa-graphql-api$ sls info
Expand All @@ -28,19 +34,18 @@ Bugs: github.com/serverless/serverless/issue

```

You'll problably see an error, if youtr AWS credentials are not thise required for SLS.

You'll problably see an error, if your AWS credentials are not thise required for SLS.

### AWS credentials

## TESTING

### Run API locally
`$> ENABLE_METRICS=0 AWS_PROFILE=toshi_batch_devops sls wsgi serve --region ap-southeast-2 --stage PROD`


### API Feature tests
`$>poetry run pytest`
`poetry run pytest`

### Run API locally
`ENABLE_METRICS=0 poetry run yarn sls wsgi serve`
poetry run yarn serverless wsgi serve



Expand Down
2 changes: 1 addition & 1 deletion nshm_hazard_graphql_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = """GNS Science New Zealand"""
__email__ = 'nshm@gns.cri.nz'
__version__ = '0.2.2'
__version__ = '0.2.3'
1 change: 1 addition & 0 deletions nshm_hazard_graphql_api/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This module exports comfiguration for the current system
"""

import os

from dotenv import load_dotenv
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Build Gridded Hazard."""

import json
import logging
import math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def edge_tiles(clipping_parts: Iterable[CustomPolygon], tiles: Iterable[CustomPo
yield clipped
else:
raise RuntimeError("Clipped tile %s is not a Polygon" % (repr(clipped.polygon())))
except (Exception) as err:
except Exception as err:
log.warning("edge_tiles raised error: %s" % err)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Schema objects for hazard."""

import graphene


Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nshm-hazard-graphql-api",
"version": "0.2.2",
"version": "0.2.3",
"description": "A graphql API for NSHM hazard.",
"scripts": {
"sls_requirements_1": "serverless requirements clean",
Expand All @@ -18,16 +18,17 @@
"homepage": "https://github.com/GNS-Science/nshm-hazard-graphql-api#readme",
"dependencies": {
"serverless": "^3.40.0",
"serverless-plugin-warmup": "^8.2.1",
"serverless-wsgi": "^3.0.2"
"serverless-plugin-warmup": "^8.3.0"
},
"devDependencies": {
"serverless-python-requirements": "^6.1.2",
"serverless-s3-local": "^0.6.22"
"serverless-s3-local": "^0.8.5",
"serverless-wsgi": "^3.1.0"
},
"overrides": {
"serverless-python-requirements": {
"serverless": "$serverless"
}
}
},
"packageManager": "yarn@4.10.2"
}
Loading