Skip to main content

service

Builds and serves the patient-data API, with no Pod involved.

This is the API child's main under Compute: everything the API needs -- the owner's username, the compute's keys, and the certificate on disk -- exists without a Pod and without a Hub session.

Module​

Functions​

build_patient_api_server​

def build_patient_api_server(    *,    username: str,    compute_name: str,    pod_key_path: Path,    compute_certificate_manager: ComputeCertificateManager,) ‑> PatientAPIServer | None:

Build the patient-data API server, not yet started.

Serves patient-eligibility data to the Trials Web App. Not built when disabled via config, or when JWT authentication is not configured (so the API is never served unauthenticated).

When a hub-issued TLS certificate has already been persisted (see ComputeCertificateManager), serves HTTPS on all interfaces so the Trials Web App can reach it from another machine on the same network; otherwise serves plain HTTP on loopback.

Arguments

  • username: The compute owner's username; the API only accepts tokens issued to it.
  • compute_name: The compute's name, which locates its background cache and image cache on disk.
  • pod_key_path: Path to the compute's RSA private key file, for decrypting its background cache.
  • compute_certificate_manager: This compute's certificate manager, for locating an already-issued TLS certificate to serve, if any.

Returns The server, or None if it is disabled or not configured.

serve_patient_api​

def serve_patient_api(username: str, compute_name: str) ‑> None:

The patient-data API child's main: serve, and live as long as serving.

Shared by every host of a Compute (the desktop orchestrator and bitfount run_compute): given only who the compute is, it finds the compute's key and whatever certificate is on disk, and serves. It never talks to the hub; the Compute registers and renews.

Exits non-zero if the server does not come up, so the Compute (or a container restart policy) can tell.

Arguments

  • username: The compute owner's username.
  • compute_name: The compute's name, which locates its key directory and cache (the pod configuration's name today).