Getting Started
RxInferServer is a web server that provides a REST API for running Bayesian inference using the RxInfer.jl package. It allows users to define probabilistic models, upload data, and run inference through HTTP requests. This guide will walk you through the installation process and shows how to start the server.
Installation
To begin using RxInferServer, first clone the repository:
git clone git@github.com:lazydynamics/RxInferServer.gitand navigate to the repository's directory by running:
cd RxInferServerWhile the server is technically implemented as a Julia package, it relies on locally auto-generated code from the OpenAPI specification. This makes it more challenging (though not impossible) to use it as a direct dependency in another Julia project. For the same reason, the server is not registered as a Julia package and cannot be installed using Pkg.jl. Please refer to the Pkg.jl documentation for more information on working with such packages.
Makefile
The repository includes a Makefile for convenience. To check the available commands, run:
make helpDatabase setup
The server requires a database to store model and inference related information. Read more about the database in the Database section. For development purposes, the server can be started with make docker command which will automatically start the database in a docker container
make dockerStarting the Server
To start the development version of the server, run:
make serveThis will automatically start Julia and call the RxInferServer.serve function with default settings. Read more about available options in the Configuration section.
It is also possible to manually start the server from the Julia REPL:
julia --projectjulia> using RxInferServer
julia> ENV["RXINFER_SERVER_ENABLE_HOT_RELOAD"] = "true"
julia> RxInferServer.serve()Note that the RxInferServer.serve is a blocking function and will keep the REPL busy. To start the server in the background, you can use the @async or Threads.@spawn macros. Read more about the @async and Threads.@spawn macros in the Julia Documentation.
Configuration
To change the configuration of the server, you can set the environment variables before starting the server. Read more about the configuration in the Configuration section. Alternatively, you can change the configuration using the .env files.
Closing the Server
To close the server, type q and hit ENTER. Alternatively, you can use the Ctrl-C shortcut.
When running the server from script, e.g. make serve, Ctrl-C might not work properly. See How do I catch CTRL-C in a script? for more information.
API Reference
RxInferServer.serve — Functionserve() -> HTTP.ServerStart the RxInfer API server with the configured settings. Official documentation is available at https://server.rxinfer.com/
Description
Initializes and starts an HTTP server that exposes RxInfer functionality through a REST API. The server uses the OpenAPI specification defined in RxInferServerOpenAPI module to register endpoints.
Features
- Configurable port via the
RXINFER_SERVER_PORTenvironment variable (default: 8000) - Graceful shutdown with proper resource cleanup when interrupted
- Loads the .env files based on the
RXINFER_SERVER_ENVenvironment variable - When
Revise.jlis loaded in the current Julia session, and theRXINFER_SERVER_ENABLE_HOT_RELOADenvironment variable is set to"true", the server will hot reload the source code and models when the source code changes.
This is a blocking operation that runs until interrupted (e.g., with Ctrl+C). To gracefully shut down the server, type the q or quit and press ENTER in the REPL. Note that Ctrl+C cannot be catched reliably when running in a non-interactive session.
Examples
using RxInferServer
# Start the server with default settings (blocks until interrupted)
RxInferServer.serve()See Also
RxInferServer.RXINFER_SERVER_ENV: The environment on which the RxInfer server will run, determines which .env files are loadedRxInferServer.RXINFER_SERVER_PORT: The port on which the RxInfer server will runRxInferServer.RXINFER_SERVER_ENABLE_HOT_RELOAD: Check if hot reloading is enabledRxInferServer.RXINFER_SERVER_SHOW_BANNER: Whether to show the welcome bannerRxInferServer.RXINFER_SERVER_LISTEN_KEYBOARD: Whether to listen for keyboard input to quit the server
Where to go next?
- Read more about the different configuration options in the Configuration section
- Create your first model with the Model management section
- For detailed information about how to create and add your own models to the server, check out the How to Add a Model manual
- If you want to contribute to the project, read more about the Development section