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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
### Changed
- Migrated to uv and ruff
- Dependency upgrades
- deps: cutoff exemptions for solvis, nshm-toshi-client
- deps: major: twine 6→7, cryptography 49→50, readme-renderer 45→46
- deps: minor (46 pkgs)
- deps: patch (22 pkgs)

## [0.9.2] 2025-10-15
### Changed
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ packages = ["solvis_graphql_api"]

[tool.uv]
exclude-newer = "1 week"
# nzshm* packages ship fresh — always resolve to latest.
exclude-newer-package = { "nzshm-common" = false, "nzshm-model" = false }
# nshm/nzshm/solvis/weka/toshi packages ship fresh — exempt from the age cutoff.
exclude-newer-package = { "nzshm-common" = false, "nzshm-model" = false, "solvis" = false, "nshm-toshi-client" = false }

[tool.ruff]
line-length = 120 # matches prior flake8 max-line-length
Expand Down
11 changes: 6 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,25 @@ commands =
[testenv:smoke]
# Smoke test that fires up the API and runs a simple query against it.
# call with
# poetry run tox -e smoke
# uv run tox -e smoke
allowlist_externals =
bash
curl
deps =
boto3
uvicorn
setenv =
PYTHONPATH = {toxinidir}
TESTING = 1
commands =
bash -c '\
flask --app solvis_graphql_api.solvis_graphql_api:app run --port 5099 & \
FLASK_PID=$!; \
for i in 1 2 3 4 5; do curl -so /dev/null http://localhost:5099/graphql 2>/dev/null && break; sleep 1; done; \
uvicorn solvis_graphql_api.app:app --port 5099 & \
SERVER_PID=$!; \
for i in $(seq 1 20); do curl -so /dev/null http://localhost:5099/graphql 2>/dev/null && break; sleep 1; done; \
RESPONSE=$(curl -sf -X POST http://localhost:5099/graphql \
-H "Content-Type: application/json" \
-d '\''{"query": "{ about }"}'\'' ); \
kill $FLASK_PID 2>/dev/null; \
kill $SERVER_PID 2>/dev/null; \
echo "$RESPONSE"; \
echo "$RESPONSE" | grep -q "solvis_graphql_api" \
'
Expand Down
4 changes: 1 addition & 3 deletions solvis_graphql_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ def _configure_logging() -> None:

app = FastAPI()
# mirror the legacy flask_cors CORS(app) default (allow all origins)
app.add_middleware(
CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"]
)
app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"])
app.include_router(GraphQLRouter(schema), prefix="/graphql")

_mangum = Mangum(app)
Expand Down
13 changes: 10 additions & 3 deletions solvis_graphql_api/color_scale/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,21 @@ def compute_colour_scale(color_scale: str, color_scale_normalise: str, vmax: flo
else:
raise RuntimeError(f"unknown normalisation option: {color_scale_normalise} ")
return ColourScaleResult(
name=color_scale, min_value=vmin, max_value=vmax, normalisation=color_scale_normalise,
levels=levels, hexrgbs=hexrgbs,
name=color_scale,
min_value=vmin,
max_value=vmax,
normalisation=color_scale_normalise,
levels=levels,
hexrgbs=hexrgbs,
)


@lru_cache
def get_colour_values(
color_scale: str, color_scale_vmax: float, color_scale_vmin: float, color_scale_normalise: str,
color_scale: str,
color_scale_vmax: float,
color_scale_vmin: float,
color_scale_normalise: str,
values: tuple[float | None],
) -> Iterable[str]:
intervals = log_intervals(color_scale_vmin, color_scale_vmax)
Expand Down
20 changes: 5 additions & 15 deletions solvis_graphql_api/data_store/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ class BinaryLargeObject:
TODO: maybe we can use the item model directly but we have issues with the get() classmethod
"""

def __init__(
self, object_id, object_type, object_meta, object_blob, client_args=None
):
def __init__(self, object_id, object_type, object_meta, object_blob, client_args=None):
self._item = BinaryLargeObjectItem(
hash_key=f"{object_type}:{object_id}",
range_key=f"{object_type}:{object_id}",
Expand All @@ -93,9 +91,7 @@ def set_s3_client_args(self, client_args: dict) -> "BinaryLargeObject":
@property
def s3_client(self):
if not self._s3_client:
self._s3_client = boto3.client(
"s3", **self._aws_client_args, region_name=REGION
)
self._s3_client = boto3.client("s3", **self._aws_client_args, region_name=REGION)
return self._s3_client

@property
Expand All @@ -108,9 +104,7 @@ def s3_connection(self):
@property
def s3_bucket(self):
if not self._s3_bucket:
self._s3_bucket = self.s3_connection.Bucket(
self._bucket_name, client=self.s3_client
)
self._s3_bucket = self.s3_connection.Bucket(self._bucket_name, client=self.s3_client)
return self._s3_bucket

@property
Expand All @@ -133,9 +127,7 @@ def object_blob(self):
log.info(f"get object_blob from bucket {self}")
try:
file_object = io.BytesIO()
self.s3_bucket.download_fileobj(
f"{self.object_type}/{self.object_id}", file_object
)
self.s3_bucket.download_fileobj(f"{self.object_type}/{self.object_id}", file_object)
file_object.seek(0)
self._object_blob = file_object.read()
except botocore.exceptions.ClientError as err:
Expand Down Expand Up @@ -227,9 +219,7 @@ def get(


def migrate():
log.info(
f"migrate() stage: {DEPLOYMENT_STAGE} offline: {IS_OFFLINE} region: {REGION} testing: {TESTING}"
)
log.info(f"migrate() stage: {DEPLOYMENT_STAGE} offline: {IS_OFFLINE} region: {REGION} testing: {TESTING}")
for table in tables:
if not table.exists():
table.create_table(wait=True)
Expand Down
Loading
Loading