Skip to main content

Standalone HTTP client for hosted and local Rescale AI inference servers

Project description

rescale-ai-client

Standalone Python client for Rescale AI hosted and local inference servers. Communicates over the shared HTTP API. No rescale_ai package dependency.

Installation

pip install rescale-ai-client

For mesh loading, prediction plotting, or VTK mesh helpers (.vtp and .vtm):

pip install "rescale-ai-client[mesh]"

For interactive 3D notebook plots:

pip install "rescale-ai-client[mesh,jupyter]"

This extra also installs jupyter_bokeh, which Panel needs for interactive rendering in VSCode notebooks.

For development:

pip install -e ".[dev]"

Protocol Sync

The committed wire DTOs under src/rescale_ai_client/_generated/ are generated from the closed-source inference server OpenAPI schema snapshot at openapi/inference-server.openapi.json.

Update flow:

# from the closed-source rescale_ai repo
PYTHONPATH=/path/to/rescale_ai \
  /path/to/rescale_ai/.venv/bin/python \
  - <<'PY'
from pathlib import Path
from rescale_ai.inference.server.openapi_compat import export_openapi_schema

export_openapi_schema(
    Path("/path/to/rescale-ai-client/openapi/inference-server.openapi.json")
)
PY

# from this repo
python scripts/generate_protocol_models.py
python scripts/generate_protocol_models.py --check

Releasing

Releases are published by GitHub Actions with uv build and uv publish.

One-time setup:

  1. In GitHub, create an environment named pypi under Settings -> Environments.
  2. In PyPI, add a trusted publisher for:
    • Owner: rescale
    • Repository: rescale-ai-client
    • Workflow: release.yml
    • Environment: pypi

No PyPI API token needs to be stored in GitHub secrets for this workflow. PyPI issues a short-lived publish credential to the tagged GitHub Actions run through OIDC.

Publish a release:

uv version 0.1.1
git commit -am "Release 0.1.1"
git tag -a v0.1.1 -m v0.1.1
git push origin main
git push origin v0.1.1

The workflow runs tests, verifies generated protocol models, builds both wheel and source distributions, smoke-tests both artifacts, and publishes to PyPI.

Quickstart

Server-available models:

from rescale_ai_client import InferenceClient

client = InferenceClient.connect(base_url="http://127.0.0.1:65432")
catalog = client.list_models()

model = catalog.model("MyModel").latest()
prediction = client.run_inference(
    "/path/to/case.vtm",
    parameters={"mach": 0.82},
    model_name=model.model_name,
    version_number=model.version_number,
)

print(prediction.global_predictions)
prediction.save("/tmp/result.vtm")

No-mesh core install, summary-only inference:

from rescale_ai_client import InferenceClient

client = InferenceClient.connect(base_url="http://127.0.0.1:65432")
summary = client.run_inference_summary(
    "/path/to/case.vtm",
    parameters={"mach": 0.82},
    model_name="MyModel",
    version_number=7,
)

print(summary.global_predictions)
print(summary.prediction_id)

Offline local-installer bundle flow:

from rescale_ai_client import InferenceClient

client = InferenceClient.connect(base_url="http://127.0.0.1:65432")

installed = client.install_bundle(
    "/path/to/MyModel_v0_local_inference.zip"
)

prediction = client.run_inference(
    "/path/to/case.vtm",
    parameters={"mach": 0.82},
    model_version_path=installed.model_version_path,
)

print(installed.model_name, installed.version_number)
print(prediction.global_predictions)

Headless license lease refresh:

from rescale_ai_client import InferenceClient

client = InferenceClient.connect(base_url="https://inference.rescale.com")
lease = client.request_license_lease(
    "eyJ...activation...",
    requested_offline_days=31,
)

print(lease.machine_id_hash)
print(lease.expires_at)
print(lease.lease_token)

extensions for optional future data

Most JSON request methods accept an optional extensions={...} payload. This is the additive escape hatch for future server features that should not force a client upgrade.

Example: send optional request hints during prediction:

from rescale_ai_client import InferenceClient

client = InferenceClient.connect(base_url="http://127.0.0.1:65432")

summary = client.run_inference_summary(
    "/path/to/case.vtm",
    parameters={"mach": 0.82},
    model_name="MyModel",
    version_number=7,
    extensions={
        "rescale": {
            "ui_session": "demo-123",
            "include_debug": True,
        }
    },
)

print(summary.extensions)
print(summary.warnings)

Example: read capability-style or server-added metadata from typed responses:

from rescale_ai_client import InferenceClient

client = InferenceClient.connect(base_url="http://127.0.0.1:65432")

server_info = client.server_info()
print(server_info.capabilities)

metadata = client.get_model_version_metadata(
    model_name="MyModel",
    version_number=7,
)
print(metadata.extensions)
print(metadata.warnings)

Design rules:

  • extensions are optional and additive
  • unknown request extensions are ignored by the server
  • unknown response extensions are ignored by clients
  • if a field becomes core contract, it should graduate into a typed top-level field

API

InferenceClient.connect(*, base_url=None, host=None, port=None, url=None, timeout=600.0)

Factory method. If omitted, defaults to local loopback at http://127.0.0.1:65432. base_url first. host / port and url remain convenience inputs. Scheme-less non-local endpoints default to HTTPS; explicit HTTP for non-local endpoints raises an InsecureConnectionWarning and stores the message on client.insecure_transport_warning.

InferenceClient.connect_via_ssh(*, ssh_user_host, remote_port=65432, ...)

SSH tunnel helper. ssh_user_host required. If remote_port is omitted, defaults to 65432.

run_inference(vtp, parameters=None, *, model=None, model_version_path=None, model_name=None, model_uuid=None, version_number=None, ...)

Canonical Python entrypoint. The vtp argument name is kept for compatibility, but path inputs may be .vtp or .vtm; .vtm paths are sent to the inference server so block structure is preserved. Same shape for hosted and local servers. CamelCase aliases still work, but new code should use snake_case. JSON request methods also accept extensions=... for optional future payloads.

run_inference_summary(...)

Lightweight entrypoint for core installs without the optional mesh dependencies. Returns typed prediction metadata plus global scalar outputs without constructing a pyvista mesh.

list_models(...)

Returns a typed ListModelsResult with helpers like .model("name"), .get("name", version_number=7), and .model("name").latest().

request_license_lease(activation_token, *, requested_offline_days=31, machine_id_hash=None, ...)

Requests a machine-bound offline lease from the hosted license endpoint. If machine_id_hash is omitted, the SDK derives a stable local machine hash automatically.

inspect_bundle(...) / install_bundle(...)

Inspect, upload, and install an offline local-inference bundle zip into the local installer. install_bundle(...) is idempotent: same content is a no-op, changed content updates the installed version.

get_model_version_metadata(version_number, *, model_name=None, model_uuid=None, ...)

Fetches typed metadata for one model version.

get_loaded_model()

Returns the server's current active-model bookkeeping status.

server_info()

Returns typed inference server capability and compatibility metadata:

  • api_version
  • supported_api_versions
  • schema_revision
  • server_build
  • capabilities

Client

Compatibility alias for one release. Use InferenceClient for new code.

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rescale_ai_client-0.1.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rescale_ai_client-0.1.0-py3-none-any.whl (45.7 kB view details)

Uploaded Python 3

File details

Details for the file rescale_ai_client-0.1.0.tar.gz.

File metadata

  • Download URL: rescale_ai_client-0.1.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rescale_ai_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b7a419429b8c863f4cb6be076402c13d2e4a4646e18b18d9a6adf88aacd3f862
MD5 8a662ffa9c9ed1c7d99edc698a23e28a
BLAKE2b-256 08f3e863d7638a4d78c43bb18c6b3ea22c9244c9483aa507c56e8135fc9e01f7

See more details on using hashes here.

File details

Details for the file rescale_ai_client-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rescale_ai_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 45.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rescale_ai_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fcb1663e768570bdb3379d9275fd33209e32b1cc62b98391920cf47e3223555
MD5 cd2638f9f5f1324d4e8a86e94b96e0c7
BLAKE2b-256 3cdf0ae3899510c512cab9eb934de631e944ad3501d1b5097c968f43088a3a53

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page