Skip to content

Repository files navigation

logo

An operating system for machine learning

Installation

pip install modelos

Configuring

ModelOS requires and OCI compliant image registry. This can be set using any of:

  • $MDL_IMAGE_REPO env var
  • tool.modelos.image_repo in pyproject.toml
  • image_repo in mdl.yaml file at project root
  • image_repo function parameters

ModelOS requires a Kubernetes cluster >= 1.22.0 and will use your current kubeconfig context.

Usage

NOTE: ModelOS is pre-alpha and under heavy development, expect breakage

Objects

Objects are distributed persistent Python objects.

A sample object

frommodelosimportObjectclassHam(Object):
temp: intweight: intbrand: strdef__init__(self, weight: int, brand: str) ->None:
self.weight=weightself.brand=branddefbake(self, temp: int) ->None:
self.temp=tempdefcut(self, weight: int) ->int:
self.weight=self.weight-weightreturnself.weight

ModelOS objects work just like Python objects with some extra capabilities.

Developing Objects

Develop on the object remotely

# Create a client which can be used to generate remote instancesHamClient=Ham.client(hot=True)
# Creates a remote instance within the context then deletes itwithHamClient(weight=12, brand="black forest") asham:
ham.bake(temp=340)
# Store the objecturi=ham.store()

Example develop URI: acme.org/ml-project:obj.ham.f2oij-2oijr-f8g2n

Releasing Objects

Release the object to be used by others. This creates a semver for the object and client/server packages

HamClient=Ham.client()
# Creates a remote instance within the context then deletes itwithHamClient(weight=14, brand="honey baked") asham:
ham.bake(temp=340)
uri=ham.release()

Example release URI: acme.org/ml-project:obj.ham.v1.2.3

Versioning scheme

v1: interface version
v1.2: class version
v1.2.3: instance version

Using Objects

Install a client from a release and use it to generate a remote instance

frommodelosimportinstallinstall("acme.org/ml-project:obj.ham.v1")
fromml_project.ham.v1importHamClient# Use the latest releasewithHamClient(weight=10) asham:
ham.bake(temp=320)
# Specify a class release versionHamClient.version="v1.2"withHamClient(weight=10) asham:
ham.bake(temp=320)
# Specify an instance versionwithHamClient.instance("v1.2.3") asham:
ham.bake(temp=320)

Install a class and use locally or remotely

frommodelosimportinstallinstall("acme.org/ml-project:obj.ham.v1.2")
fromml_project.ham.v1_2importHam# locallyham=Ham(weight=12)
ham.bake(temp=300)
# remotelywithHam.client()(weight=10) asham:
ham.bake(temp=320)

Install an instance and use it locally

frommodelosimportinstallinstall("acme.org/ml-project:obj.ham.v1.2.3")
fromml_project.ham.v1_2_3importHam# load the object instance stateham=Ham.from_env()
ham.bake(temp=400)

An example working project can be found at https://github.com/pbarker/kvd

Packages

Packages are versioned filesystems

frommodelos.pkgimportPkg, clean# Create a new package from the ./data dirpkg=Pkg("foo", "./data", "A foo package", remote="acme.org/ml-project")
# See package contentspkg.show()
# Push the package to its remotepkg.push()
# List files in the packagefiles=pkg.ls()
# Open a file in the packagewithpkg.open("./foo.yaml") asf:
b=f.read()
# Release the packagepkg.release("v0.0.1", labels={"type": "foo"}, tags=["baz"])
# Check the latest package is our releaseassertpkg.latest() =="v0.0.1"# Delete the packagepkg.delete()
# Describe a remote packageinfo=Pkg.describe("acme.org/ml-project:pkg.fs.bar.v1.2.3")
# Use a remote packagebar_pkg=Pkg("bar", version="v1.2.3", remote="acme.org/ml-project")
# Clean packagesclean("acme.org/ml-project", "foo")

See the tests for more examples

Roadmap

  • Releasing
  • Properties
  • Packages
  • Environments
  • Runtimes
  • Extension objects
  • Finding / indexing
  • Docs / landing
  • UI / CLI
  • Schema
  • Bi-directional streaming
  • Smarter versioning

About

An operating system for machine learning

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages