fastrdf.serve¶
python -m fastrdf.serve: serves a serialized model with Model.serve, configured with
environment variables, as a container or VM deployment does.
The environment variables:
MODEL_URL The model to serve: a file or folder written by Model.serialize, as a
path or URL (gs://bucket/model.fastrdf, az://container/model, ...).
Required.
STORAGE memory (default), hybrid or disk.
STORAGE_FOLDER Where hybrid and disk storage keep their files. Default /data/fastrdf.
CACHE_SIZE With disk storage and a folder URL: bytes of downloaded triple tables to
keep (e.g. 50GB, 500MB, or a number of bytes). Default: keep all.
FASTRDF_AUTH_TOKEN Requests must carry "Authorization: Bearer <token>". Strongly
recommended; unset means no authentication.
PORT HTTP port, default 8080 (Cloud Run and Container Apps set it).
FLIGHT_PORT Arrow Flight port. Default: no Flight.
ALLOW_UPDATE true to accept SPARQL updates. Default false.
SNAPSHOT_URL With ALLOW_UPDATE: where to serialize the model, every
SNAPSHOT_INTERVAL seconds (default 900) when it changed, and on
shutdown when it changed. Usually the same as MODEL_URL.
SERVICE_ENDPOINTS Comma-separated endpoints that SERVICE in queries may reach, e.g.
https://query.wikidata.org/sparql, or * for any http(s) URL. Default:
none, so clients can not make the server send requests.
ALLOW_LOAD true to allow SPARQL Update LOAD of URLs in SERVICE_ENDPOINTS (with
ALLOW_UPDATE). Default false.
STORAGE_OPTIONS Object storage options as JSON, e.g. {"azure_storage_account_name": "x"}.
Usually not needed: credentials come from the machine's identity.
WARMUP true (default) runs a small query before serving, so the first user
query is not slower than the rest. The default is false for disk
storage from a folder URL, where it would download every table.
All of Model.serve’s endpoints are served, among them /sparql (SPARQL 1.1 Protocol) and /health. The port opens once the model is loaded.
SIGTERM (sent by Cloud Run, Container Apps and systemd before stopping) and SIGINT stop the server, which takes a last snapshot if the model changed since the previous one.
Functions¶
|