qrunch.hybrid_jobs.docker_image

Logic for creating a docker file that can be used to run a hybrid job on.

Classes

HybridJobDockerImage

Built docker image.

HybridJobDockerImageCreator

Hybrid docker image builder for specifying the docker image.

Exceptions

EcrLoginError

Error raised when login to ECR fails.

exception EcrLoginError

Bases: RuntimeError

Error raised when login to ECR fails.

__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class HybridJobDockerImage

Bases: object

Built docker image.

__init__(builder: HybridJobDockerImageCreator) None

Initialize a HybridJobDockerImage.

Should always be done through the Builder.build() method to ensure the image i actually build.

Parameters:

builder (HybridJobDockerImageCreator) – Builder that have build the image.

Return type:

None

push_to_ecr(repository_name: str, *, create_repository: bool = False) str

Push docker image to AWS ECR and return url to image.

Parameters:
  • repository_name (str) – Name of repository to push to.

  • create_repository (bool) – If True a repository is created in the region, if it does not exist.

Return type:

str

property region: str

Get the region where the Docker image is being uploaded to.

class HybridJobDockerImageCreator

Bases: object

Hybrid docker image builder for specifying the docker image.

__init__(*, image_name: str, region_name: str, cloudsmith_token: str) None

Initialize a hybrid docker image builder for specifying the docker image.

If no QDK version is given the latest version will be used.

Parameters:
  • image_name (str) – Name of image to build.

  • region_name (str) – region the image should work in.

  • cloudsmith_token (str) – The token used when downloading the wheel from the Cloudsmith repository

Return type:

None

create() HybridJobDockerImage

Create docker image a return a reference to the image, that can be pushed to ECR.

Return type:

HybridJobDockerImage

with_base_image(base_image: Framework) Self

Choose which base image to use. Can be: Framework.BASE Framework.PL_TENSORFLOW, Framework.PL_PYTORCH.

Parameters:

base_image (Framework) – Base image to use. From braket.jobs.Framework.

Return type:

Self

with_qrunch_version(version: str) Self

Choose version of Kvantify Qrunch to use for the docker image.

Parameters:

version (str) – Version string of the format x.y.z, that matches a released version of Kvantify Qrunch.

Return type:

Self

with_requirement(name: str, version: str) Self

Add a python pip requirement of the form name==version.

Parameters:
  • name (str) – Name of the python pip requirement

  • version (str) – Version of the requirement

Return type:

Self

with_requirements_txt(requirements_path: Path | str) Self

Add requirements from a standard requirements.txt file.

Parameters:

requirements_path (Path | str) – Path to requirements.txt file.

Return type:

Self

docker_image_creator(image_name: str, region_name: str, cloudsmith_token: str) HybridJobDockerImageCreator

Start creating a docker image for hybrid jobs.

Parameters:
  • image_name (str) – Name of the docker image to create.

  • region_name (str) – Region the image should be built for. Must match the AWS region of the device the job will run on.

  • cloudsmith_token (str) – The token used when downloading the QDK from the cloudsmith repository.

Return type:

HybridJobDockerImageCreator