Skip to content

Environments

Deployment versions and training experiments make use of environments. An environment is the system that runs the code of deployments or training experiments. It consists of the operating system and any required libraries or other dependencies on top of that. Environments are Docker containers, either built in UbiOps or your own uploaded containers.

Environments and the code of your deployments are managed separately. This enables you to re-use the same environment for multiple deployments, which will reduce build times and enable you to standardise the environment between multiple deployments.

There are two ways to build an environment:

  • picking a base environment and adding dependencies on top this base environment using the UbiOps build system
  • uploading your own Docker image directly

Base Environments and dependencies

Base environments are prepared by UbiOps and are Ubuntu containers with Python pre-installed. We also have prepared base environments with CUDA-drivers, to support instance types with GPU support. You can find all base environments supported by UbiOps in the WebApp by going to Environments and then the Base environments tab.

An example overview of base environments in UbiOps:

base-environments

You can create a custom environment out of a base environment, by adding additional dependency specifications on top. This way, you can supplement the base environment with additional dependencies (including your own, e.g. from a custom pip repo), OS-level dependencies, or your own CUDA-version.

Keeping your environments as small as possible will result in a faster cold start time, as the environment is loaded in every time an instance is started.

UbiOps provides several Tutorials and How-to's that guide you through setting up UbiOps environments.

Uploading dependency information

Dependencies in an environment can be installed by uploading environment files with dependency information to UbiOps. You can specify what dependencies you want to use with these environment files, which can be either one or more of the following files:

  • requirements.txt - A list of Python packages required for the deployment. UbiOps will install the packages defined in this file for you using a fresh pip virtual environment once you upload your deployment. After this build step the dependencies are fixed and won't change. Read more about the requirements.txt file format and possibilities here.

  • libraries/ - directory where unpacked packages and system libraries can be added that will be used in your deployment. This directory is added to the system $PATH variable during runtime. The directory is not available during build time.

  • A ubiops.yamlfile for installing OS level packages in the container. For more information see installing OS level packages.

Using the CLI to create the zip for you

You can also make use of the UbiOps command line interface to create the zip for you and upload it to reduce manual work.

Validating environment files locally

These files can be validated locally with the validate function.

Uploading one of these files (or a zip of multiple) to your environment will trigger a new build and create a new Revision for your environment. A revision is defined as an uploaded environment package. You can get information, like the status, about a revision by navigating to the Revision tab in the environment details page.

The XGBoost tutorial for example uses Python 3.9 as a base environment, with a requirements.txt with the following dependencies:

pandas==1.4.2
numpy==1.21.5
scikit-learn==1.0.2
scipy==1.7.3
xgboost==1.6.2
joblib==1.1.0

After uploading the deployment package, with this requirements.txt a custom environment will be implicitly created, and added to your list of custom environments.

Using public or private Git libraries is also possible by following this guide.

If the Python package is hosted on a different pip repository than the default PyPI repository, you can add a link to this custom pip repository by following this guide.

Bring Your Own Docker Image

Docker images is an experimental feature

Uploading your own Docker images is an experimental feature in UbiOps. Please contact us for access and more information, and for support with deploying your own workloads.

Environments can also be created directly from a Docker image. In that case UbiOps does not build a new Docker image, but uses the uploaded image as an environment instead. Such an environment based on a custom Docker images allows more flexibility in installing libraries, private repositories and other software in the environment.

The Docker image can contain any logic. It can either still follow the UbiOps request format, or be a completely stand-alone application, such as a Jupyter notebook. Please read the documentation for Supporting request format, Preparing the Docker archive and Creating the environment in Bring Your Own Docker Image

Exporting and uploading your Docker image

Docker images can be loaded into UbiOps using the Docker save and import functionality. Please read here how to create a custom Docker environment in UbiOps and how to upload your Docker image to it.

Custom Docker environments can be used as normal environments when creating a deployment version or a training experiment.

  • If you want to make use of UbiOps request functionality, both the deployment and environment must have enabled the "support request format" setting.
  • If you are deploying an application that does not use UbiOps requests, automatic scaling for your deployment is disabled, and you can only select a fixed number of instances.

The custom Docker image feature is not enabled by default, please contact us if you want to try it out.

Managing environments

You can manage your environments using the WebApp, the Python Client Library and Command Line Interface (CLI).

In the WebApp you can find both the base environments that UbiOps offers and your own custom environments by going to the Environments tab.

environments-tab

Create a custom environment

Custom environments can be created in two ways:

  • Explicitly: By creating an environment in the Environments tab in the WebApp. When creating a deployment version or a training experiment later, you can select your custom environment from the environment dropdown. An example of this is shown in the XGBoost training tutorial. For an explicit custom environment you need to provide the following:

    • Name
    • When using base environments and dependencies, the base environment you would like to use and either a single dependency file, or a zipped folder that includes multiple dependency files
    • When using Docker images, a file that contains the Docker image
    • Description (optional)
    • Labels (optional)
  • Implicitly: which is done by adding environment files (the files mentioned in the Uploading dependency information section) to your deployment package. UbiOps will then generate a custom environment for you by adding the dependencies specified in these environment files to the base environment that you selected. UbiOps will give this new custom environment a name that consists of the base environment + deployment name + deployment version + 8 random characters, e.g. Python3.9-xgboost-deployment-v1-xxxxxxxx, and the label Created_by: UbiOps. This method is applied in the Tensorflow template tutorial.

Environments can also be created via CLI with the command ubiops environments deploy.

Updating environments

You can update a custom environment in the WebApp by clicking on the custom environment, and then on the Edit button on the top. You can then edit the name, add or remove labels, and upload new dependency files.

Updating an active environment

Changing an environment affects all deployment versions and/or training experiments that use that environment.

edit-custom-environment

Environments can be re-deployed via the CLI with the command ubiops environments deploy.

Have a look at our Tutorials if you want to see some examples of how to define and use environments in your deployment versions and training experiments.