Advanced guides
Feature Server
Establishing an online source can necessitate additional infrastructure work, such as setting up a Redis cluster. Developers might want to avoid installing extra dependencies on a server that only handles predictions. Consequently, they might prefer not having the feature store in memory, but rather as a separate service. This could be due to the usage of a programming language such as Rust, which may not yet support the feature store.
This is where the feature server proves beneficial. We can specify our requirement for a server code that functions as an online source, and Aligned will facilitate the structuring of all API calls, generate an OpenAPI schema for documentation, and handle reading from the online source. Therefore, a server can be set up with only 3 lines of code.
Example
Starting a feature server requires very little. All you need is to run aligned serve
in the same folder as your feature-store.json
file.
Custom Path
By default will aligned serve
look for a file called worker.py
and an object called server
. However, it is possible to overwrite this using the --server-path
flag.
E.g: aligned serve --server-path my/path.py:server_object
However, if you have stored your features somewhere else can you define a server.py
file and setup something similar to. Therefore, you can point to a S3
file, and it will load all features in that file.
from aligned import RedisConfig, FileSource
from aligned.schemas.repo_definition import FeatureServer
store = FileSource.json_at("feature-store.json")
server = FeatureServer.from_reference(
store,
online_source=RedisConfig.localhost()
)
This will start up a server at http://localhost:8000, and will look something like the image bellow.
We need the POST call her to pass a HTTP body.