Model Registry

At runtime, the production lifecycle uses the model registry for storing artifacts of project lineages as well as the models of its generations.

ForML can use multiple registries built upon different technologies. The available registry implementations are:

forml.lib.registry.virtual

Virtual registry is a dummy registry implementation that doesn’t persist anything outside of the current runtime.

forml.lib.registry.filesystem

Filesystem registry is a plain hierarchical file based locally-accessible structure.

API

class forml.runtime.asset.persistent.Registry(*args, **kwargs)[source]

Top-level persistent registry abstraction.

Return type

Interface

abstract close(project, lineage, generation, tag)[source]

Seal new generation by storing its metadata tag.

Parameters
  • project (prjmod.Level.Key) – Project to store the metadata into.

  • lineage (lngmod.Level.Key) – Lineage of the project to store the metadata into.

  • generation (genmod.Level.Key) – Generation of the project to store the metadata into.

  • tag (genmod.Tag) – Generation metadata to be stored.

Return type

None

abstract generations(project, lineage)[source]

List the generations of given lineage.

Parameters
  • project (prjmod.Level.Key) – Project of which the lineage is to be listed.

  • lineage (lngmod.Level.Key) – Lineage of the project to be listed.

Returns

Generations listing.

Return type

Iterable[Union[str, int, genmod.Level.Key]]

abstract lineages(project)[source]

List the lineages of given project.

Parameters

project (prjmod.Level.Key) – Project to be listed.

Returns

Lineages listing.

Return type

Iterable[Union[str, lngmod.Level.Key]]

mount(project, lineage)[source]

Take given project/lineage package and return it as artifact instance.

Parameters
  • project (prjmod.Level.Key) – Name of the project to work with.

  • lineage (lngmod.Level.Key) – Lineage to be loaded.

Returns

Product artifact.

Return type

product.Artifact

abstract open(project, lineage, generation)[source]

Return the metadata tag of given generation.

Parameters
  • project (prjmod.Level.Key) – Project to read the metadata from.

  • lineage (lngmod.Level.Key) – Lineage of the project to read the metadata from.

  • generation (genmod.Level.Key) – Generation of the project to read the metadata from.

Returns

Generation metadata.

Return type

genmod.Tag

abstract projects()[source]

List projects in given repository.

Returns

Projects listing.

Return type

Iterable[Union[str, prjmod.Level.Key]]

abstract pull(project, lineage)[source]

Return the package of given lineage.

Parameters
  • project (prjmod.Level.Key) – Project of which the lineage artifact is to be returned.

  • lineage (lngmod.Level.Key) – Lineage of the project to return the artifact of.

Returns

Project artifact object.

Return type

distribution.Package

abstract push(package)[source]

Start new lineage of a project based on given artifact.

Parameters

package (distribution.Package) – Distribution package to be persisted.

Return type

None

abstract read(project, lineage, generation, sid)[source]

Load the state based on provided id.

Parameters
  • project (prjmod.Level.Key) – Project to read the state from.

  • lineage (lngmod.Level.Key) – Lineage of the project to read the state from.

  • generation (genmod.Level.Key) – Generation of the project to read the state from.

  • sid (uuid.UUID) – Id of the state object to be loaded.

Returns

Serialized state or empty byte-array if there is no such state for given (existing) generation.

Return type

bytes

abstract write(project, lineage, sid, state)[source]

Dump an unbound state under given state id.

Parameters
  • project (prjmod.Level.Key) – Project to store the state into.

  • lineage (lngmod.Level.Key) – Lineage of the project to store the state into.

  • sid (uuid.UUID) – state id to associate the payload with.

  • state (bytes) – Serialized state to be persisted.

Return type

None