Flumina Server Apps Reference
Reference documentation for Flumina Server Apps
Authoring Flumina Server Apps
Prerequisites
Ensure you follow the installation steps in the Quick Start.
Initialize a Flumina Repository
The core organization concept in firectl is that of an app. An app is a directory that contains the following:
-
Code that defines the behavior of the Server App
- Crucially,
flumina.py
defines the “entrypoint” that the Fireworks infrastructure understands and uses to bring up the necessary infrastructure
- Crucially,
-
(recommended) Serialized weights for deep learning models
- We highly recommend packaging weights inside the repository to be loaded locally on the server. Downloading weights at server initialization is discouraged.
As in the quick start, let’s initialize an empty repository using the flumina
CLI tool that was installed with the fireworks-ai
package:
The flumina init app
command will add a few things in the present directory:
-
fireworks.json
marks the directory as a Flumina repository for downstream tools. You don’t need to edit this -
flumina.py
defines the entrypoint for the Server App. This is where you should add your model calling and business logic. We will cover this below -
requirements.txt
. This is where you can specify Python package dependencies in piprequirements
format. The Fireworks service will install these before running your app. -
The
data
directory is provided for convenience. It is recommended to place assets like model weights in this directory and reference them via relative paths within your code. -
(Hidden files like
.fluminaignore
are also present. You can ignore these for now)
flumina.py: Server App Definition
flumina.py
is the script that the Fireworks service invokes when running your Server App. FluminaModule
is the main interface on which you will add your logic. The default template contains a FluminaModule
with minimal functionality implemented. You can change this as you wish to develop your Server App. A summary of the key parts:
__init__
__init__
is where you should initialize assets to be used by the server. This includes deep learning modules (PyTorch nn.Modules
) and auxiliary state.
Routes
The main way that logic in your Server App is exposed to the outside world is through routes. Flumina uses a design similar to FastAPI for route definition: methods on your FluminaModule
should have a route decorator applied to them to expose the logic as an API endpoint. For example, from the template:
This code exposes a route called /infer
as an API endpoint. Pydantic objects are used to define the input and output data. Basically what this defines is an API that you can call. The example printed out by flumina deploy
, for example, is generated from the registered routes on your app:
Entrypoints
The default app script has two entrypoints:
-
if __name__ == "__flumina_main__"
. Fireworks will call this entrypoint to deploy your module in the cloud. You don’t need to modify this in most cases. -
if __name__ == "__main__"
. Call this entrypoint locally to test your model before deploying to Fireworks.
There are other aspects of FluminaModule that we will cover later.
Examples
We have used Flumina to deploy our newest production image generation workloads. See the following for examples:
Was this page helpful?