Warning
This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.
galaxy.containers package¶
Interfaces to containerization software
-
class
galaxy.containers.
ContainerPort
(port: int, protocol: str, hostaddr: str, hostport: int)[source]¶ Bases:
tuple
Named tuple representing ports published by a container, with attributes
-
property
port
¶ Alias for field number 0
-
property
protocol
¶ Alias for field number 1
-
property
hostaddr
¶ Alias for field number 2
-
property
hostport
¶ Alias for field number 3
-
property
-
class
galaxy.containers.
ContainerVolume
(path, host_path=None, mode=None)[source]¶ Bases:
object
-
valid_modes
= frozenset({'ro', 'rw'})¶
-
__init__
(path, host_path=None, mode=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
abstract
from_str
(as_str)[source]¶ Classmethod to convert from this container type’s string representation.
- Parameters
as_str (str) – string representation of volume
-
property
mode_is_valid
¶
-
-
class
galaxy.containers.
Container
(interface, id, name=None, **kwargs)[source]¶ Bases:
object
-
__init__
(interface, id, name=None, **kwargs)[source]¶ - Parameters
interface (
ContainerInterface
subclass instance) – Container interface for the given container typeid (str) – Container identifier
name (str) – Container name
-
property
id
¶ The container’s id
-
property
name
¶ The container’s name
-
abstract
from_id
(interface, id)[source]¶ Classmethod to create an instance of Container from the container system’s id for the given container type.
- Parameters
interface (
ContainerInterface
subclass instance) – Container insterface for the given idid (str) – Container identifier
- Returns
Container object
- Return type
Container
subclass instance
-
abstract property
ports
¶ Attribute for accessing details of ports published by the container.
- Returns
Port details
- Return type
list of
ContainerPort
s
-
abstract property
address
¶ Attribute for accessing the address or hostname where published ports can be accessed.
- Returns
Hostname or IP address
- Return type
-
abstract
is_ready
()[source]¶ Indicate whether or not the container is “ready” (up, available, running).
- Returns
True if ready, else False
- Rtpe
bool
-
map_port
(port)[source]¶ Map a given container port to a host address/port.
For legacy reasons, if port is
None
, the first port (if any) will be returned- Parameters
port (int) – Container port to map
- Returns
Mapping to host address/port for given container port
- Return type
ContainerPort
instance
-
-
class
galaxy.containers.
ContainerInterface
(conf, key, containers_config_file)[source]¶ Bases:
object
-
container_class
: Optional[Type[galaxy.containers.Container]] = None¶
-
volume_class
= typing.Union[typing.Type[galaxy.containers.ContainerVolume], NoneType]¶
-
publish_port_list_required
= False¶
-
supports_volumes
= True¶
-
__init__
(conf, key, containers_config_file)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
property
key
¶
-
property
containers_config_file
¶
-
-
galaxy.containers.
build_container_interfaces
(containers_config_file, containers_conf=None)[source]¶ Build
ContainerInterface`s. Pass ``containers_conf`
to avoid rereading the config file.- Parameters
- Returns
Instantiated container interfaces with keys corresponding to
containers
keys- Return type
dict of
ContainerInterface
subclass instances
-
galaxy.containers.
parse_containers_config
(containers_config_file)[source]¶ Parse a
containers_conf.yml
and return the contents of itscontainers
dictionary.
Submodules¶
galaxy.containers.docker module¶
Interface to Docker
-
class
galaxy.containers.docker.
DockerInterface
(conf, key, containers_config_file)[source]¶ Bases:
galaxy.containers.ContainerInterface
-
container_class
¶
-
volume_class
¶
-
conf_defaults
: Dict[str, Optional[Any]] = {'auto_remove': True, 'cpus': None, 'force_tlsverify': False, 'host': None, 'image': None, 'memory': None, 'tls': False}¶
-
conf_run_kwopts
= ('cpus', 'memory')¶
-
image_repodigest
(image)[source]¶ Get the digest image string for an image.
- Parameters
image (str) – image id or image name and optionally, tag
- Returns
digest string, having the format <name>@<hash_alg>:<digest>, e.g.: ‘bgruening/docker-jupyter-notebook@sha256:3ec0bc9abc9d511aa602ee4fff2534d80dd9b1564482de52cb5de36cce6debae’ or, the original image name if the digest cannot be determined (the image has not been pulled)
-
property
host
¶
-
property
host_iter
¶
-
-
class
galaxy.containers.docker.
DockerCLIInterface
(conf, key, containers_config_file)[source]¶ Bases:
galaxy.containers.docker.DockerInterface
-
conf_defaults
: Dict[str, Optional[Any]] = {'command_template': '{executable} {global_kwopts} {subcommand} {args}', 'executable': 'docker'}¶
-
option_map
: Dict[str, Dict] = {'auto_remove': {'flag': '--rm', 'type': 'boolean'}, 'cpus': {'flag': '--cpus', 'type': 'string'}, 'detach': {'flag': '--detach', 'type': 'boolean'}, 'environment': {'flag': '--env', 'type': 'list_of_kvpairs'}, 'memory': {'flag': '--memory', 'type': 'string'}, 'name': {'flag': '--name', 'type': 'string'}, 'publish_all_ports': {'flag': '--publish-all', 'type': 'boolean'}, 'publish_port_random': {'flag': '--publish', 'type': 'string'}, 'volumes': {'flag': '--volume', 'type': 'docker_volumes'}}¶
-
-
class
galaxy.containers.docker.
DockerAPIClient
(*args, **kwargs)[source]¶ Bases:
object
Wraps a
docker.APIClient
to catch exceptions.
-
class
galaxy.containers.docker.
DockerAPIInterface
(conf, key, containers_config_file)[source]¶ Bases:
galaxy.containers.docker.DockerInterface
-
host_config_option_map
= {'auto_remove': {}, 'binds': {}, 'cpus': {'map': <function DockerAPIInterface.<lambda>>, 'param': 'nano_cpus'}, 'memory': {'param': 'mem_limit'}, 'port_bindings': {}, 'publish_all_ports': {}}¶
-
galaxy.containers.docker_decorators module¶
Decorators for docker
galaxy.containers.docker_model module¶
Model objects for docker objects
-
class
galaxy.containers.docker_model.
DockerAttributeContainer
(members=None)[source]¶ Bases:
object
-
property
members
¶
-
property
-
class
galaxy.containers.docker_model.
DockerVolume
(path, host_path=None, mode=None)[source]¶
-
class
galaxy.containers.docker_model.
DockerContainer
(interface, id, name=None, inspect=None)[source]¶ Bases:
galaxy.containers.Container
-
classmethod
from_id
(interface, id)[source]¶ Classmethod to create an instance of Container from the container system’s id for the given container type.
- Parameters
interface (
ContainerInterface
subclass instance) – Container insterface for the given idid (str) – Container identifier
- Returns
Container object
- Return type
Container
subclass instance
-
property
ports
¶ Attribute for accessing details of ports published by the container.
- Returns
Port details
- Return type
list of
ContainerPort
s
-
property
address
¶ Attribute for accessing the address or hostname where published ports can be accessed.
- Returns
Hostname or IP address
- Return type
-
is_ready
()[source]¶ Indicate whether or not the container is “ready” (up, available, running).
- Returns
True if ready, else False
- Rtpe
bool
-
property
inspect
¶
-
classmethod
-
class
galaxy.containers.docker_model.
DockerService
(interface, id, name=None, image=None, inspect=None)[source]¶ Bases:
galaxy.containers.Container
-
classmethod
from_id
(interface, id)[source]¶ Classmethod to create an instance of Container from the container system’s id for the given container type.
- Parameters
interface (
ContainerInterface
subclass instance) – Container insterface for the given idid (str) – Container identifier
- Returns
Container object
- Return type
Container
subclass instance
-
property
ports
¶ Attribute for accessing details of ports published by the container.
- Returns
Port details
- Return type
list of
ContainerPort
s
-
property
address
¶ Attribute for accessing the address or hostname where published ports can be accessed.
- Returns
Hostname or IP address
- Return type
-
is_ready
()[source]¶ Indicate whether or not the container is “ready” (up, available, running).
- Returns
True if ready, else False
- Rtpe
bool
-
property
inspect
¶
-
property
state
¶ If one of this service’s tasks desired state is running, return that task state, otherwise, return the state of a non-running task.
This is imperfect because it doesn’t attempt to provide useful information for replicas > 1 tasks, but it suits our purposes for now.
-
property
env
¶
-
property
image
¶
-
property
cpus
¶
-
property
constraints
¶
-
property
tasks
¶ A list of all tasks, including terminal ones.
-
property
task_count
¶ A count of all tasks, including terminal ones.
-
classmethod
-
class
galaxy.containers.docker_model.
DockerServiceConstraint
(name=None, op=None, value=None)[source]¶ Bases:
object
-
__init__
(name=None, op=None, value=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
property
name
¶
-
property
op
¶
-
property
value
¶
-
property
label
¶
-
-
class
galaxy.containers.docker_model.
DockerServiceConstraints
(members=None)[source]¶ Bases:
galaxy.containers.docker_model.DockerAttributeContainer
-
member_class
¶ alias of
DockerServiceConstraint
-
property
labels
¶
-
-
class
galaxy.containers.docker_model.
DockerNode
(interface, id=None, name=None, status=None, availability=None, manager=False, inspect=None)[source]¶ Bases:
object
-
__init__
(interface, id=None, name=None, status=None, availability=None, manager=False, inspect=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
property
id
¶
-
property
name
¶
-
property
version
¶
-
property
inspect
¶
-
property
state
¶
-
property
cpus
¶
-
property
labels
¶
-
property
labels_as_constraints
¶
-
property
tasks
¶ A list of all tasks, including terminal ones.
-
property
non_terminal_tasks
¶
-
property
task_count
¶ A count of all tasks, including terminal ones.
-
-
class
galaxy.containers.docker_model.
DockerNodeLabel
(name=None, value=None)[source]¶ Bases:
object
-
__init__
(name=None, value=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
property
name
¶
-
property
value
¶
-
property
constraint_string
¶
-
property
constraint
¶
-
-
class
galaxy.containers.docker_model.
DockerNodeLabels
(members=None)[source]¶ Bases:
galaxy.containers.docker_model.DockerAttributeContainer
-
member_class
¶ alias of
DockerNodeLabel
-
property
constraints
¶
-
-
class
galaxy.containers.docker_model.
DockerTask
(interface, id=None, name=None, image=None, desired_state=None, state=None, error=None, ports=None, service=None, node=None)[source]¶ Bases:
object
-
terminal_states
= ('shutdown', 'complete', 'failed', 'rejected', 'orphaned')¶
-
__init__
(interface, id=None, name=None, image=None, desired_state=None, state=None, error=None, ports=None, service=None, node=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
property
id
¶
-
property
name
¶
-
property
inspect
¶
-
property
slot
¶
-
property
node
¶
-
property
service
¶
-
property
cpus
¶
-
property
state
¶
-
property
current_state
¶
-
property
current_state_time
¶
-
property
desired_state
¶
-
property
terminal
¶
-
galaxy.containers.docker_swarm module¶
Docker Swarm mode interface
-
class
galaxy.containers.docker_swarm.
DockerSwarmInterface
(conf, key, containers_config_file)[source]¶ Bases:
galaxy.containers.docker.DockerInterface
-
container_class
¶
-
conf_defaults
: Dict[str, Optional[Any]] = {'ignore_volumes': False, 'managed': True, 'manager_autostart': True, 'node_prefix': None, 'resolve_image_digest': False, 'service_create_cpus_constraint': False, 'service_create_image_constraint': False}¶
-
publish_port_list_required
= True¶
-
supports_volumes
= False¶
-
-
class
galaxy.containers.docker_swarm.
DockerSwarmCLIInterface
(conf, key, containers_config_file)[source]¶ Bases:
galaxy.containers.docker_swarm.DockerSwarmInterface
,galaxy.containers.docker.DockerCLIInterface
-
option_map
: Dict[str, Dict] = {'availability': {'flag': '--availability', 'type': 'string'}, 'constraint': {'flag': '--constraint', 'type': 'list_of_kovtrips'}, 'cpu_limit': {'flag': '--limit-cpu', 'type': 'string'}, 'cpu_reservation': {'flag': '--reserve-cpu', 'type': 'string'}, 'environment': {'flag': '--env', 'type': 'list_of_kvpairs'}, 'label_add': {'flag': '--label-add', 'type': 'list_of_kvpairs'}, 'label_rm': {'flag': '--label-rm', 'type': 'list_of_kvpairs'}, 'mem_limit': {'flag': '--limit-memory', 'type': 'string'}, 'mem_reservation': {'flag': '--reserve-memory', 'type': 'string'}, 'name': {'flag': '--name', 'type': 'string'}, 'publish_port_random': {'flag': '--publish', 'type': 'string'}, 'replicas': {'flag': '--replicas', 'type': 'string'}, 'restart_condition': {'flag': '--restart-condition', 'type': 'string'}}¶
-
-
class
galaxy.containers.docker_swarm.
DockerSwarmAPIInterface
(conf, key, containers_config_file)[source]¶ Bases:
galaxy.containers.docker_swarm.DockerSwarmInterface
,galaxy.containers.docker.DockerAPIInterface
-
placement_option_map
= {'constraint': {'param': 'constraints'}}¶
-
service_mode_option_map
= {'replicas': {'default': 1}, 'service_mode': {'default': 'replicated', 'param': 0}}¶
-
resources_option_map
= {'cpus': {'map': <function DockerSwarmAPIInterface.<lambda>>, 'params': ('cpu_limit', 'cpu_reservation')}, 'memory': {'params': ('mem_limit', 'mem_reservation')}}¶
-
container_spec_option_map
= {'command': {}, 'environment': {'param': 'env'}, 'image': {'param': 0}, 'labels': {}}¶
-
restart_policy_option_map
= {'restart_condition': {'default': 'none', 'param': 'condition'}, 'restart_delay': {'param': 'delay'}, 'restart_max_attempts': {'param': 'max_attemps'}}¶
-
task_template_option_map
= {'_container_spec': {'required': True, 'spec_class': None}, '_placement': {'spec_class': None}, '_resources': {'spec_class': None}, '_restart_policy': {'spec_class': None}}¶
-
node_spec_option_map
= {'availability': {'param': 'Availability'}, 'labels': {'param': 'Labels'}, 'name': {'param': 'Name'}, 'role': {'param': 'Role'}}¶
-