Docker

Classes for running a Gretel Job as a local container

class gretel_client.projects.docker.ContainerRun(job: gretel_client.projects.jobs.Job)

Runs a Gretel Job from a local container.

Parameters

job – Job to run as docker container.

property active

Returns True if the container is running. False otherwise.

container_output_dir: Optional[str] = None

Output directory on the container where artifacts placed.

property container_status

Status from the running docker container.

Valid statuses include:

created, restarting, running, removing, paused, exited, or dead

If the container isn’t running, an “unknown” status will be returned.

delete()

Remove the docker container

graceful_shutdown()

Attempts to gracefully shutdown the container run.

image: str = None

The container image used for running the job

is_ok()

Checks to see if the container is ok.

Raises

ContainerRunError if there is a problem with the container.

model: Model = None

The model associated with the container run

output_dir: Optional[Path] = None

Local file path to save artifacts to.

start()

Run job via a local container. This method is async and will return after the job has started.

If you wish to block until the container has finished, the wait method may be used.

stop(force: bool = False)

If there is a running container this command will stop that container.

Parameters

force – If force is True, SIGKILL will be sent to the container, otherwise SIGTERM.

wait(timeout: int = 30)

Blocks until a running container has completed. If the container hasn’t started yet, we wait until a timeout interval is reached.

Parameters

timeout – The time in seconds to wait for a container to start. If the timeout is reached, the function will return.

exception gretel_client.projects.docker.ContainerRunError
exception gretel_client.projects.docker.DockerEnvironmentError
gretel_client.projects.docker.check_docker_env()

Checks that the local docker env is configured.

Raises
  • DockerEnvironmentError if the docker environment isn't

  • configured correctly.

gretel_client.projects.docker.extract_container_path(container: docker.models.containers.Container, container_path: str, host_path: str)

Writes all files from a container path to a host path