Apart from defining pipeline steps based on jobs and scripts, you can use custom
container images to define the step runtime.
You can select the container image, command, or entry point for container execution. You can
provide the custom code in a script or a compressed archive, which lets you update the code
without rebuilding the image.
BYOC Step Configuration
(Optional)
Select From container.
Under Container configuration, select
Configure.
In the Configure your container environment panel:
Select a repository from the list. If the repository is in a
different compartment, select Change
compartment.
Select an image from the list.
(Optional) Enter an entry point. To add another, select
+Add parameter.
(Optional) Enter a CMD. To add another, select +Add
parameter.
(Optional) Enter an image digest.
(Optional) If using signature verification, enter the OCID of the
image signature. For example,
ocid1.containerimagesignature.oc1.iad.aaaaaaaaab....
Select Select.
(Optional)
Upload the step artifact by dragging it into the box. This step is optional
only if BYOC is configured.
Model Artifact 🔗
Uploading a step artifact when using BYOC is optional. However, it lets you change the
code that runs inside the container without rebuilding the image.
The step artifacts are mounted in the container to the folder
/home/datascience/. If an artifact is an archive, its content is
extracted to the folder /home/datascience/decompressed_artifact.
Common docker image
It's convenient to build a generic container image with the required environment (for
example, Python 3.8 and basic libraries as shown in Quick start) and add Python scripts
later as step artifacts.
Custom artifacts - folder override
When you use a custom step artifact, the service mounts a volume with the artifact to
the /home/datascience folder, overriding the folder in your
container image. Archive artifacts (zip/tar/...) are decompressed
and the content is presented in the folder
/home/datascience/decompressed_artifact.
Create a Container Pipeline - Quick Start 🔗
Follow these steps to create a container pipeline step.
Building the Container 🔗
Use an existing image in the OCI
Registry or create a new image using the sample Dockerfile. Here is the sample
code that builds an image that lets you run Python scripts.
Dockerfile:
Copy
FROM python:3.8-slim AS base
ENV DATASCIENCE_USER datascience
ENV DATASCIENCE_UID 1000
ENV HOME /home/$DATASCIENCE_USER
RUN python -m pip install \
oci \
ocifs
COPY simplest.py .
CMD ["python", "simplest.py"]
The Dockerfile assumes that the script,
simplest.py is in the same folder. Here is sample
code for simplest.py:
Copy
import datetime
import os
import time
pipe_id = os.environ.get("PIPELINE_RUN_OCID", "LOCAL")
print(f"Starting pipeline run: {pipe_id}")
print(f"Current timestamp in UTC: {datetime.datetime.utcnow()}")
print("Delay 5s")
time.sleep(5)
print("Environment variables:")
for item, value in os.environ.items():
print(f"\t {item}: {value}")
Run the docker build command:
Copy
docker build -t byoc:1.0.0 .
Testing the Container 🔗
Before pushing the image to a container registry, you can test it locally.
Run the image locally:
Copy
docker run --rm -it -v "/home/lin/.oci:/home/datascience/.oci" byoc:1.0.0
docker tag <local_image_name>:<local_version><region>.ocir.io/<tenancy_ocir_namespace>/<repo>:<version>
docker tag byoc:1.0.0 iad.ocir.io/testtenancy/byoc:1.0.0
See the Pipeline Policies section to ensure that you have
policies that let the pipeline run resource pull container images from the container
registry.
Create a pipeline to use the container.
Create a pipeline with an appropriate name, for example, BYOC
Demo name.
Select Add pipeline steps.
Give the step a name, for example, Step 1.
To use Bring Your Own Container, select From
container.
In Container configuration, select
Configure.
In Configure your container environment:
Select the repository quickstart or byoc from the list. If the
repository is in a different compartment, select
Change compartment.
Select the image,
iad.ocir.io/idtlxnfdweil/quickstart/byoc:1.0.0,
from the list.
Select Select.
Select Save.
Optional: Define logging.
Select Create.
Enabling the Pipeline Logs 🔗
Create a pipeline and start
it.This task it optional, if you don't want to generate the logs, you can ignore it.
From the list of pipelines, select the pipeline you want to enable.
From the pipeline details page, select Logs.
Select Enable logs.
Supported Configurations 🔗
Important information about configurations that are supported.
ML Pipelines only support container images residing in the OCI Registry.
The size of the container image is limited to 40 GB in uncompressed form.
The user who creates the ML Pipeline resource must have access to the container image in
the OCI Registry. If not, create a user access
IAM policy before creating the ML Pipeline
resource.
Images in a container registry are identified by repository, name, and a tag. Also,
Docker gives each version of an image a unique alphanumeric digest. When pushing an updated
container image, we recommend giving the updated image a new tag to identify it, rather than
reusing an existing tag, as best practice. However, even if you push an updated image and
give it the same name and tag as an earlier version, the newly pushed version has a
different digest to the earlier version.
When you create a pipeline resource, you specify the name and tag of a particular version
of an image. To avoid inconsistencies later on, pipelines also record the unique digest of
that particular version of the image. You can also provide the digest of the image when
creating the pipeline resource.
By default, if you push an updated version of an image to the Docker registry with
the same name and tag as the original version of the image, pipelines continue to use
the original digest to pull the original version of the image. This might be the
behavior that you require. However, if you want pipelines to pull the later version of
the image, you can explicitly change the image name with the tag and digest that
pipelines use to identify which version of the image to pull.