Images API Reference

Images

class neuro_sdk.Images

Docker image subsystem.

Used for pushing docker images onto Neuro docker registry for later usage by Jobs.run() and pulling these images back to local docker.

coroutine push(local: LocalImage, remote: Optional[RemoteImage] = None, *, progress: Optional[AbstractDockerImageProgress] = None) RemoteImage[source]

Push local docker image to remote side.

Parameters:
  • local (LocalImage) – a spec of local docker image (e.g. created by docker build) for pushing on Neuro Registry.

  • remote (RemoteImage) – a spec for remote image on Neuro Registry. Calculated from local image automatically if None (default).

  • progress (AbstractDockerImageProgress) – a callback interface for reporting pushing progress, None for no progress report (default).

Returns:

remote image if explicitly specified, calculated remote image if remote is None (RemoteImage)

coroutine pull(remote: Optional[RemoteImage] = None, local: LocalImage, *, progress: Optional[AbstractDockerImageProgress] = None) RemoteImage[source]

Pull remote image from Neuro registry to local docker side.

Parameters:
  • remote (RemoteImage) – a spec for remote image on Neuro registry.

  • local (LocalImage) – a spec of local docker image to pull. Calculated from remote image automatically if None (default).

  • progress (AbstractDockerImageProgress) – a callback interface for reporting pulling progress, None for no progress report (default).

Returns:

local image if explicitly specified, calculated remote image if local is None (LocalImage)

coroutine digest(image: RemoteImage) str[source]

Get digest of an image in Neuro registry.

Parameters:

image (RemoteImage) – a spec for remote image on Neuro registry.

Returns:

string representing image digest

coroutine rm(image: RemoteImage, digest: str) str[source]

Delete remote image specified by given reference and digest from Neuro registry.

Parameters:
  • image (RemoteImage) – a spec for remote image on Neuro registry.

  • digest (str) – remote image digest, which can be obtained via digest method.

coroutine list(cluster_name: Optional[str] = None) List[RemoteImage][source]

List images on Neuro registry available to the user.

Parameters:

cluster_name (str) –

name of the cluster.

None means the current cluster (default).

Returns:

list of remote images not including tags (List[RemoteImage])

coroutine tags(image: RemoteImage) List[RemoteImage][source]

List image references with tags for the specified remote image.

Parameters:

image (RemoteImage) – a spec for remote image without tag on Neuro registry.

Returns:

list of remote images with tags (List[RemoteImage])

coroutine size(image: RemoteImage) int[source]

Return image size.

Parameters:

image (RemoteImage) – a spec for remote image with tag on Neuro registry.

Returns:

remote image size in bytes

coroutine tag_info(image: RemoteImage) Tag[source]

Return info about specified tag.

Parameters:

image (RemoteImage) – a spec for remote image with tag on Neuro registry.

Returns:

tag information (name and size) (Tag)

AbstractDockerImageProgress

class neuro_sdk.AbstractDockerImageProgress

Base class for image operations progress, e.g. Images.pull() and Images.push(). Inherited from abc.ABC.

pull(data: ImageProgressPull) None[source]

Pulling image from remote Neuro registry to local Docker is started.

Parameters:

data (ImageProgressPull) – additional data, e.g. local and remote image objects.

push(data: ImageProgressPush) None[source]

Pushing image from local Docker to remote Neuro registry is started.

Parameters:

data (ImageProgressPush) – additional data, e.g. local and remote image objects.

step(data: ImageProgressStep) None[source]

Next step in image transfer is performed.

Parameters:

data (ImageProgressStep) – additional data, e.g. image layer id and progress report.

ImageProgressPull

class neuro_sdk.ImageProgressPull

Read-only dataclass for pulling operation report.

src

Source image, RemoteImage instance.

dst

Destination image, LocalImage instance.

class neuro_sdk.ImageProgressPush

Read-only dataclass for pulling operation report.

src

Source image, LocalImage instance.

dst

Destination image, RemoteImage instance.

class neuro_sdk.ImageProgressStep

Read-only dataclass for push/pull progress step.

layer_id

Image layer, str.

message

Progress message, str.

LocalImage

class neuro_sdk.LocalImage

Read-only dataclass for describing image in local Docker system.

name

Image name, str.

tag

Image tag (str), None if the tag is omitted (implicit latest tag).

RemoteImage

class neuro_sdk.RemoteImage

Read-only dataclass for describing image in remote registry (Neuro Platform hosted or other registries like DockerHub).

name

Image name, str.

tag

Image tag (str), None if the tag is omitted (implicit latest tag).

owner

User name (str) of a person who manages this image.

Public DockerHub images (e.g. "ubuntu:latest") have no owner, the attribute is None.

org_name

Name (str) of an organization who manages this image or None if there is no such org.

Public DockerHub images (e.g. "ubuntu:latest") have no org, the attribute is None.

registry

Host name for images hosted on Neuro Registry (str), None for other registries like DockerHub.

as_docker_url(with_scheme: bool = False) str[source]

URL that can be used to reference this image with Docker.

Parameters:

with_scheme (bool) – if set to True, returned URL includes scheme (https://), otherwise (default behavior) - scheme is omitted.

with_tag(tag: bool) RemoteImage

Creates a new reference to remote image with tag.

Parameters:

tag (str) – new tag

Returns:

remote image with tag

classmethod new_neuro_image(name: str, registry: str, *, owner: str, cluster_name: str, tag: Optional[str] = None) RemoteImage[source]

Create a new instance referring to an image hosted on Neuro Platform.

Parameters:
  • name (str) – name of the image

  • registry (str) – registry where the image is located

  • owner (str) – image owner name

  • cluster_name (str) – name of the cluster

  • tag (str) – image tag

classmethod new_external_image(name: str, registry: Optional[str] = None, *, tag: Optional[str] = None) RemoteImage[source]

Create a new instance referring to an image hosted on an external registry (e.g. DockerHub).

Parameters:
  • name (str) – name of the image

  • registry (str) – registry where the image is located

  • tag (str) – image tag

class neuro_sdk.Tag

Read-only dataclass for tag information.

name

Tag name, str.

size

Tag size in bytes, int.