shepherd.sheep

Classes

  • BaseSheep: A base class for container adapters - classes that allow launching different kinds of containers.

  • DockerSheep: Sheep running its jobs in docker containers.

  • BareSheep: An adapter that running models on bare metal with shepherd-runner.

class shepherd.sheep.BaseSheep(socket, sheep_data_root)[source]

Bases: object

A base class for container adapters - classes that allow launching different kinds of containers.

Inheritance diagram of BaseSheep

class Config(raw_data=None, trusted_data=None, deserialize_mapping=None, init=True, partial=True, strict=True, validate=False, app_data=None, lazy=False, **kwargs)[source]

Bases: schematics.deprecated.patch_models.<locals>.Model

__init__(socket, sheep_data_root)[source]

Create new BaseSheep.

Parameters
  • socket (Socket) – socket for feeding sheep’s runner with InputMessages

  • sheep_data_root (str) – sheep data root with job working directories

_load_model(model_name, model_version)[source]

Tell the sheep to prepare a new model (without restarting).

Return type

None

abstract property running: bool

Is the sheep running, i.e. capable of accepting computation requests?

Return type

bool

start(model_name, model_version)[source]

(Re)start the sheep with the given model name and version. Any unfinished jobs will be lost, socket connection will be reset.

Parameters
  • model_name (str) – model name

  • model_version (str) – model version

Return type

None

class shepherd.sheep.DockerSheep(config, registry_config, command=None, **kwargs)[source]

Bases: shepherd.sheep.base_sheep.BaseSheep

Sheep running its jobs in docker containers. To enable GPU computation, specify the gpu devices in the configuration and sheep will attempt to use nvidia docker 2.

Inheritance diagram of DockerSheep

class Config(raw_data=None, trusted_data=None, deserialize_mapping=None, init=True, partial=True, strict=True, validate=False, app_data=None, lazy=False, **kwargs)[source]

Bases: shepherd.sheep.base_sheep.BaseSheep.Config

_CONTAINER_POINT = 9999

Container port to bind the socket to.

__init__(config, registry_config, command=None, **kwargs)[source]

Create new DockerSheep.

Parameters
  • config (Dict[str, Any]) – docker sheep configuration

  • registry_config (RegistryConfig) – docker registry configuration

  • command (Optional[List[str]]) – optional docker container run command

  • kwargsBaseSheep’s kwargs

_load_model(model_name, model_version)[source]

Pull docker image of the given name and version from the previously configured docker registry.

Parameters
  • model_name (str) – docker image name

  • model_version (str) – docker image version

Return type

None

property running: bool

Check if the underlying docker container is running.

Return type

bool

slaughter()[source]

Kill the underlying docker container.

Return type

None

start(model_name, model_version)[source]

Run a docker command starting the docker runner.

Parameters
  • model_name (str) – docker image name

  • model_version (str) – docker image version

Return type

None

class shepherd.sheep.BareSheep(config, **kwargs)[source]

Bases: shepherd.sheep.base_sheep.BaseSheep

An adapter that running models on bare metal with shepherd-runner. This might be useful when Docker isolation is impossible or not necessary, for example in deployments with just a few models.

Inheritance diagram of BareSheep

class Config(raw_data=None, trusted_data=None, deserialize_mapping=None, init=True, partial=True, strict=True, validate=False, app_data=None, lazy=False, **kwargs)[source]

Bases: shepherd.sheep.base_sheep.BaseSheep.Config

__init__(config, **kwargs)[source]

Create new BareSheep.

Parameters
_load_model(model_name, model_version)[source]

Set up runner config path to working_directory / model_name / model_version / config.yaml.

Parameters
  • model_name (str) – model name

  • model_version (str) – model version

Raises

SheepConfigurationError – if the runner config path does not exist

Return type

None

property running: bool

Check if the underlying runner (subprocess) is running.

Return type

bool

slaughter()[source]

Kill the underlying runner (subprocess).

Return type

None

start(model_name, model_version)[source]

Start a subprocess with the sheep runner.

Parameters
  • model_name (str) – model name

  • model_version (str) – model version

Return type

None