Skip to main content

Model releases

A model release is a versioned package of the code in a model. This is useful when a model is ready to use in a test, staging or production envrionment.

SAPACK file format

When releasing a model, SA Engine always packs the model into a SAPACK (.s.fcz) file format.

SAPACK is a file format where all files are first compressed using Lz77 and then concatenated together with a header telling the unpacker what compression to use. Essentially it is a light-weight version of tar + gzip.

Creating a release

You can release a model with the models:create_release() function. Releasing a model takes the model from your models folder, packs it and stores the compressed model file in a folder called model_releases in your SA_HOME.

Try creating a release of our new model:

models:create_release("my_model","1.0");
Not connected

To run this code block you must be logged in and your studio instance must be started.

We can verify that a release was created by running the function models:installed(), which lists the models in your model_releases folder in SA_HOME:

models:installed();
Not connected

To run this code block you must be logged in and your studio instance must be started.

The result should include the model we just released:

"my_model@1.0.s.fcz"

Released models have the format <name>@<version>.s.fcz.

Publishing a release

Model releases are stored in artifact repositories called Model repositories. The first and most simple storage location is the model_releases folder in SA_HOME. This is called the Local model repository.

To distribute a model release to edges, it should first be published to a Central model repository. In any federation, the nameserver can act as the central repository.

To publish a model to a server repository you use the models:publish command. The following query publishes version 1.0 of model "my-model" to the server:

models:publish("my-model", "1.0");

This uploads the model release to the default repository on the server. You can specify the repository by providing the repository name as the first parameter.

models:publish("default", "my-model", "1.0");
Alternative repositories

For larger federations, where SA federation services are used, the central repository is database backed and has been tested on scale.

It is also possible to setup a custom repository solution, using Github or AWS as a repository.

Regardless of which repository solution is used, the command to publish a release to the server is the same.

Import published models

To load a published model release on an edge device, use the models:import command. The command should be executed on the edge.

//peer: my-edge
models:import("my-model", "1.0");

Import vs Deploy

The figure below shows a summary of functions for working with model releases in a federation. Note that models in development can either be deployed directly, or made into releases which are first published and then imported to an edge.

Model ecosystem in a federation. Models in development can be deployed directly while released models are first published and then imported.

Note

There can only be one model with the same name in the edge SA Engine instance. Even though imported and deployed models come from different sources, they replace each other. It is the last loaded version of the model that is used, regardless of which code is newer.

When SA Engine loads a model, all functions belonging to the previously loaded version will first be dropped. After that, the functions belonging to the currently loaded version will be defined. It is not advisable to use the functions during this process.

Working locally with a model release

It is also possible to import a model release locally. In that case the the model is imported directly from the local model repository, and no publishing step is needed.

The model release package file can also be shared by sending it outside the SA Engine infrastructure. To import a .fcz file from disk, use the function models:install(charstring file, charstring model_name, charstring version) where file is the path to the file and model_name and version can be used to tag the model with new name and version.

models:install(sa_home()+"model_releases/my_model@1.0.s.fcz",
"my_model2","1.1");
Not connected

To run this code block you must be logged in and your studio instance must be started.

We can verified that the new model was installed with the models:installed() function:

models:installed();
Not connected

To run this code block you must be logged in and your studio instance must be started.

The figure below shows a summary of functions for working with model releases locally.

model_management_overview_2.png

Model ecosystem in a local client. Models in development can be loaded and model releases can be imported directly.