From 7696e8a986fb70cb6285f042bca3c630cfb0bb8a Mon Sep 17 00:00:00 2001 From: Anne Reinarz Date: Tue, 4 Aug 2026 11:41:17 +0100 Subject: [PATCH 1/4] convert to numpy scalar automatically --- umbridge/um.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/umbridge/um.py b/umbridge/um.py index e3041d9..534de7f 100755 --- a/umbridge/um.py +++ b/umbridge/um.py @@ -6,6 +6,17 @@ import numpy as np import threading + +def _to_native(value): + # Convert numpy scalar/array types to native Python types. + if isinstance(value, np.ndarray): + return value.tolist() + if isinstance(value, np.generic): + return value.item() + if isinstance(value, list): + return [_to_native(v) for v in value] + return value + class Model(object): def __init__(self, name): @@ -413,7 +424,7 @@ async def evaluate(request): if len(output[i]) != output_sizes[i]: return error_response("InvalidOutput", f"Output vector {i} has invalid length! Model declared {output_sizes[i]} but returned {len(output[i])}.", 500) - return web.Response(text=f"{{\"output\": {output} }}") + return web.Response(text=f"{{\"output\": {_to_native(output)} }}") @routes.post('/EvaluateShMem') async def evaluate(request): @@ -519,7 +530,7 @@ async def gradient(request): if len(output) != input_sizes[in_wrt]: return error_response("InvalidOutput", f"Output vector has invalid length! Model declared {input_sizes[in_wrt]} but returned {len(output)}.", 500) - return web.Response(text=f"{{\"output\": {output} }}") + return web.Response(text=f"{{\"output\": {_to_native(output)} }}") @routes.post('/GradientShMem') @@ -631,7 +642,7 @@ async def applyjacobian(request): if len(output) != output_sizes[out_wrt]: return error_response("InvalidOutput", f"Output vector has invalid length! Model declared {output_sizes[out_wrt]} but returned {len(output)}.", 500) - return web.Response(text=f"{{\"output\": {output} }}") + return web.Response(text=f"{{\"output\": {_to_native(output)} }}") @routes.post('/ApplyJacobianShMem') async def applyjacobian(request): @@ -744,7 +755,7 @@ async def applyhessian(request): if len(output) != output_sizes[out_wrt]: return error_response("InvalidOutput", f"Output vector has invalid length! Model declared {output_sizes[out_wrt]} but returned {len(output)}.", 500) - return web.Response(text=f"{{\"output\": {output} }}") + return web.Response(text=f"{{\"output\": {_to_native(output)} }}") @routes.post('/ApplyHessianShMem') async def applyhessian(request): @@ -817,7 +828,7 @@ async def get_input_sizes(request): model = get_model_from_name(model_name) if model is None: return model_not_found_response(req_json["name"]) - return web.Response(text=f"{{\"inputSizes\": {model.get_input_sizes(config)} }}") + return web.Response(text=f"{{\"inputSizes\": {_to_native(model.get_input_sizes(config))} }}") @routes.post('/OutputSizes') async def get_output_sizes(request): @@ -830,7 +841,7 @@ async def get_output_sizes(request): model = get_model_from_name(model_name) if model is None: return model_not_found_response(req_json["name"]) - return web.Response(text=f"{{\"outputSizes\": {model.get_output_sizes(config)} }}") + return web.Response(text=f"{{\"outputSizes\": {_to_native(model.get_output_sizes(config))} }}") @routes.post('/ModelInfo') async def modelinfo(request): From d66a8cab21b5c46bb18e98f7e3581c13a201b904 Mon Sep 17 00:00:00 2001 From: Anne Reinarz Date: Tue, 4 Aug 2026 11:52:02 +0100 Subject: [PATCH 2/4] pip update to skip versions --- .github/workflows/pip-update.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/pip-update.yml b/.github/workflows/pip-update.yml index 5640f6a..118069c 100644 --- a/.github/workflows/pip-update.yml +++ b/.github/workflows/pip-update.yml @@ -1,26 +1,19 @@ # This workflow will upload a Python Package using Twine when a release is created # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries - # This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by # separate terms of service, privacy policy, and support # documentation. - name: Upload Python Package - on: push: branches: - 'main' - permissions: contents: read - jobs: deploy: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - name: Set up Python @@ -34,8 +27,8 @@ jobs: - name: Build package run: python -m build - name: Publish package - continue-on-error: true uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} + skip-existing: true From 3710373681b80e7246a121eda052f23deb2dab22 Mon Sep 17 00:00:00 2001 From: Anne Reinarz Date: Tue, 4 Aug 2026 11:52:30 +0100 Subject: [PATCH 3/4] bump version@ --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 99cb3af..c948728 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="umbridge", - version="1.2.5", + version="1.2.6", author="UM-Bridge", author_email="", description="UM-Bridge (the UQ and Model Bridge) provides a unified interface for numerical models that is accessible from virtually any programming language or framework. It is primarily intended for coupling advanced models (e.g. simulations of complex physical processes) to advanced statistical or optimization methods.", From 488710a286ce7969dd460c01c9bcf3cd3fc03776 Mon Sep 17 00:00:00 2001 From: Anne Reinarz Date: Tue, 4 Aug 2026 12:14:22 +0100 Subject: [PATCH 4/4] update to current pypi authentication guidelines --- .github/workflows/pip-update.yml | 7 ++++++- setup.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pip-update.yml b/.github/workflows/pip-update.yml index 118069c..d07d444 100644 --- a/.github/workflows/pip-update.yml +++ b/.github/workflows/pip-update.yml @@ -14,6 +14,11 @@ permissions: jobs: deploy: runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/umbridge + permissions: + id-token: write steps: - uses: actions/checkout@v3 - name: Set up Python @@ -27,7 +32,7 @@ jobs: - name: Build package run: python -m build - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/setup.py b/setup.py index c948728..814f4b8 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="umbridge", - version="1.2.6", + version="1.2.7", author="UM-Bridge", author_email="", description="UM-Bridge (the UQ and Model Bridge) provides a unified interface for numerical models that is accessible from virtually any programming language or framework. It is primarily intended for coupling advanced models (e.g. simulations of complex physical processes) to advanced statistical or optimization methods.",