Skip to main content

Private packages

Packages are directories of Python files that can be installed using pip. Packages include a config file that specifies a name, version and dependencies in a setup.py or pyproject.toml. You can upload your private Python packages to Modelbit to make them available to all of your deployments.

Adding packages

To add your package to Modelbit from the command line, run:

modelbit package add /path/to/the/package

Or from within a notebook authenticated with Modelbit:

mb.add_package("/path/to/the/package")

The /path/to/the/package should be the directory containing the setup.py or pyproject.toml.

After adding your package to Modelbit, it will be automatically included in deployments made from notebooks with mb.deploy() if your deployment uses the package. If mb.deploy() doesn't detect that the package is used you can also add it with the python_packages= argument.

If you are creating a deployment with git, add the package and version to the requirements.txt file, (e.g. my_package==0.1.2).

Overwriting existing versions

If you made changes to your package and want to replace the version in Modelbit without incrementing the version number, use the force parameter.

On the command line:

modelbit package add --force /path/to/the/package

From within a notebook:

mb.add_package("/path/to/the/package", force=True)

New deployments will install the new version of the package. Previously created deployments models will not receive the updated package.

Adding wheels

Prebuilt packages can be wheels (.whl) or source distributions (.tar.gz). To upload a prebuilt package to Modelbit, use the same syntax as in adding packages, but point to the package's file instead of the source directory.

On the command line:

modelbit package add /path/to/the/package.whl

# or, if overwriting a version
modelbit package add --force /path/to/the/package.whl

Or from a notebook:

mb.add_package("/path/to/the/package.whl")

# or, if overwriting a version
mb.add_package("/path/to/the/package.whl", force=True)

Using uploaded packages

No code changes are needed to use your private packages from within a Modelbit deployment. You can use both import my_package and from my_package import foo import formats with your inference function:

from my_package import foo

def predict(a: int):
return foo(a)

mb.deploy(predict)

Viewing and deleting private packages

To see the private packages stored in Modelbit, head to the Packages area of in the top navigation. Deleting a package from here will remove it from the list of packages to install for new deployments. Deployments already using the package will not be affected, as the package is already installed in the deployment's environment.