Persisting Models

After you got yourself a Model instance, you can persist it to a repository. For that, you need a Task instance to add model to. Task is a container for models trained for the same problem. For example, if you did some experiments, you’ll push each experiment as a Model to the same Task.

Each Task belongs to a Project, which is just container for tasks.

To create and persist projects, tasks and models, you need ebonite client, which is and instance of Ebonite. Ebonite client is a composition of two repository implementations: MetadataRepository and ArtifactRepository.

MetadataRepository is where all the metadata goes, you look at it as a SQL database (we actually have an sql implementation).

ArtifactRepository is where all model binaries go. It can be any file storage like s3, ftp and so on.

You can manually create client with Ebonite(metadata_repository, artifact_repository), or use one of the factory methods: local() for local client (metadata will just a json file, and artifacts will be just plain files in local file system), inmemory() for in-memory repositories.

Also there is a custom_client() to setup your own repositories.

You can use MetadataRepository.type value as for metadata argument.

Available implementations:

You can use ArtifactRepository.type value as for artifact argument.

Available implementations:

Let’s create local ebonite client (code):

1
ebnt = ebonite.Ebonite.local(clear=True)

Now, create project and task for our model (code):

1
#  then push it to repositories. this will create .ebonite dir with metadata.json and artifacts dir

And push model into it (code):

1

Now, if you take a look at .ebonite directory, you’ll find a metadata.json file with your project, task and model.

Congratulations, you persisted your model. This process is absolutely the same if you choose other repository implementations. Take a look at examples/remote_example for an example with remote repositories.