Image API Reference
Customer-hosted cloud features
Some features are only available on customer-hosted clouds. Reach out to preview-help@anyscale.com for info.
Image Models
ImageBuild
ImageBuild(uri: str, status: Union[str, anyscale.image.models.ImageBuildStatus], ray_version: Optional[str])
Fields
uri
(str): The URI of the image for the build.status
(str | ImageBuildStatus): The status of the image build.ray_version
(str | None): The Ray version used for the image build.
Python Methods
def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""
Examples
- Python
- CLI
import anyscale
from anyscale.models import ImageBuild, ImageBuildStatus
image_build: ImageBuild = anyscale.image.get("image-name")
$ anyscale image get -n my-image
uri: anyscale/image/my-image:2
status: SUCCEEDED
ImageBuildStatus
An enumeration.
Values
IN_PROGRESS
: The image build is in progress.SUCCEEDED
: The image build succeeded.FAILED
: The image build failed.UNKNOWN
: The CLI/SDK received an unexpected state from the API server. In most cases, this means you need to update the CLI.
Image CLI
anyscale image build
Usage
anyscale image build [OPTIONS]
Build an image from a Containerfile.
Options
--containerfile/-f
: Path to the Containerfile.--name/-n
: Name for the image. If the image with the same name already exists, a new version will be built. Otherwise, a new image will be created.--ray-version/-r
: The Ray version (X.Y.Z) specified for this image specified by either an image URI or a containerfile. If not provided, the latest Ray version will be used.
anyscale image get
Usage
anyscale image get [OPTIONS]
Get details of an image.
Options
--name/-n
: Get the details of an image.
The name can contain an optional version, e.g., 'name:version'. If no version is provided, the latest one will be used.
Image SDK
anyscale.image.build
Build an image from a Containerfile.
Returns the URI of the image.
Arguments
containerfile
(str): The content of the Containerfile.name
(str): The name of the image.ray_version
(str | None) = None: The version of Ray to use in the image
Returns: str
Examples
- Python
import anyscale
containerfile = '''
FROM anyscale/ray:2.21.0-py39
RUN pip install --no-cache-dir pandas
'''
image_uri: str = anyscale.image.build(containerfile, name="mycoolimage")
anyscale.image.get
The name can contain an optional version tag, i.e., 'name:version'.
If no version is provided, the latest one will be returned.
Arguments
name
(str): Get the details of an image.
The name can contain an optional version, e.g., 'name:version'. If no version is provided, the latest one will be used.
Returns: ImageBuild
Examples
- Python
import anyscale
image_status = anyscale.image.get(name="mycoolimage")