6.1. wc_env_manager package¶
6.1.1. Subpackages¶
6.1.2. Submodules¶
6.1.3. wc_env_manager.__main__ module¶
wc_env_manager command line interface
- Author
Arthur Goldberg <Arthur.Goldberg@mssm.edu>
- Date
2018-04-04
- Copyright
2018, Karr Lab
- License
MIT
-
class
wc_env_manager.__main__.
AllController
(*args, **kw)[source]¶ Bases:
cement.ext.ext_argparse.ArgparseController
Build, push, pull, and remove images and containers
-
class
wc_env_manager.__main__.
App
(label=None, **kw)[source]¶ Bases:
cement.core.foundation.App
Command line application
-
class
Meta
[source]¶ Bases:
object
-
handlers
= [<class 'wc_env_manager.__main__.BaseController'>, <class 'wc_env_manager.__main__.BaseImageController'>, <class 'wc_env_manager.__main__.ImageController'>, <class 'wc_env_manager.__main__.NetworkController'>, <class 'wc_env_manager.__main__.ContainerController'>, <class 'wc_env_manager.__main__.AllController'>][source]¶
-
-
class
-
class
wc_env_manager.__main__.
BaseController
(*args, **kw)[source]¶ Bases:
cement.ext.ext_argparse.ArgparseController
Base controller for command line application
-
class
wc_env_manager.__main__.
BaseImageController
(*args, **kw)[source]¶ Bases:
cement.ext.ext_argparse.ArgparseController
Build, push, and pull the base image, wc_env_dependencies
-
class
wc_env_manager.__main__.
ContainerController
(*args, **kw)[source]¶ Bases:
cement.ext.ext_argparse.ArgparseController
Build and remove containers of wc_env
-
class
wc_env_manager.__main__.
ImageController
(*args, **kw)[source]¶ Bases:
cement.ext.ext_argparse.ArgparseController
Build, push, and pull the image, wc_env
6.1.4. wc_env_manager._version module¶
6.1.5. wc_env_manager.core module¶
Tools for managing computing environments for whole-cell modeling
Build the Docker image
wc_env: image with WC models and WC modeling tools and their dependencies
wc_env_dependencies: base image with third party dependencies
Remove the Docker images
Push/pull the Docker images
Create Docker containers
Mount host directories into container
Copy files (such as configuration files and authentication keys) into container
Install GitHub SSH key
Verify access to GitHub
Install Python packages in mounted directories from host
Copy files to/from Docker container
List Docker containers of the image
Get CPU, memory, network usage statistics of Docker containers
Stop Docker containers
Remove Docker containers
Login to DockerHub
- Author
Jonathan Karr <jonrkarr@gmail.com>
- Author
Arthur Goldberg <Arthur.Goldberg@mssm.edu>
- Date
2018-08-23
- Copyright
2018, Karr Lab
- License
MIT
-
class
wc_env_manager.core.
WcEnvManager
(config=None)[source]¶ Bases:
object
Manage computing environments (Docker containers) for whole-cell modeling
-
config
[source]¶ Dictionary of configuration options. See wc_env_manager/config/core.schema.cfg.
- Type
configobj.ConfigObj
-
_base_image_unsquashed
[source]¶ unsquasehd version of the current base Docker image
- Type
docker.models.images.Image
-
build_base_image
()[source]¶ Build base Docker image for WC modeling environment
Before executing this method, you must download CPLEX and obtain licenses for Gurobi, MINOS, Mosek, and XPRESS. See the documentation <building_images> for more information.
- Returns
Docker image
- Return type
docker.models.images.Image
-
build_container
(tty=True)[source]¶ Create Docker container for WC modeling environmet
- Parameters
tty (
bool
) – ifTrue
, allocate a pseudo-TTY- Returns
Docker container
- Return type
docker.models.containers.Container
-
build_image
()[source]¶ Build Docker image for WC modeling environment
- Returns
Docker image
- Return type
docker.models.images.Image
- Raises
WcEnvManagerError – if a copied configuration file clashes with
-
copy_path_from_container
(container_path, local_path, overwrite=True)[source]¶ Copy file/directory from Docker container
Implemented using subprocess because docker-py does not (as 2018-08-22) provide a copy method.
- Parameters
container_path (
str
) – path to file/directory within containerlocal_path (
str
) – local path to copy file/directory from containeroverwrite (
bool
, optional) – ifTrue
, overwrite file
- Raises
WcEnvManagerError – if the container_path already exists and
overwrite
isFalse
-
copy_path_to_container
(local_path, container_path, overwrite=True, container_user=<WcEnvUser.root: 0>)[source]¶ Copy file or directory to Docker container
Implemented using subprocess because docker-py does not (as 2018-08-22) provide a copy method.
- Parameters
local_path (
str
) – path to local file/directory to copy to containercontainer_path (
str
) – path to copy file/directory within containeroverwrite (
bool
, optional) – ifTrue
, overwrite file
- Raises
WcEnvManagerError – if the container_path already exists and
overwrite
isFalse
-
get_config_file_paths_to_copy_to_image
()[source]¶ Get list of configuration file paths to copy from ~/.wc to Docker image
- Returns
configuration file paths to copy from ~/.wc to Docker image
- Return type
list
ofdict
-
get_container_stats
()[source]¶ Get statistics about the CPU, io, memory, network performance of the Docker container
- Returns
statistics about the CPU, io, memory, network performance of the Docker container
- Return type
dict
-
get_containers
(sort_by_read_time=False)[source]¶ Get list of Docker containers that are WC modeling environments
- Parameters
sort_by_read_time (
bool
) – ifTrue
, sort by read time in descending order (latest first)- Returns
- list of Docker containers
that are WC modeling environments
- Return type
list
ofdocker.models.containers.Container
-
get_image_version
(image)[source]¶ Get the version of the Docker image
- Parameters
image (
docker.models.images.Image
) – image- Returns
docker image version
- Return type
str
-
get_latest_container
()[source]¶ Get current Docker container
- Returns
Docker container
- Return type
docker.models.containers.Container
-
get_latest_image
(image_repo)[source]¶ Get the lastest version of the Docker image for the WC modeling environment
- Parameters
image_repo (
str
) – image repository- Returns
Docker image
- Return type
docker.models.images.Image
-
get_required_python_packages
()[source]¶ - Get Python packages required for the WC models and WC modeling
tools (config[‘image’][‘python_packages’])
- Returns
- list of Python requirements in
requirements.txt format
- Return type
list
ofstr
-
make_container_name
()[source]¶ Create a timestamped name for a Docker container
- Returns
container name
- Return type
str
-
pull_image
(image_repo, image_tags)[source]¶ Pull Docker image for WC modeling environment
- Parameters
image_repo (
str
) – image repositoryimage_tags (
list
ofstr
) – list of tags
- Returns
Docker image
- Return type
docker.models.images.Image
-
push_image
(image_repo, image_tags)[source]¶ Push Docker image to DockerHub
- Parameters
image_repo (
str
) – image repositoryimage_tags (
list
ofstr
) – list of tags
-
remove_container
(force=False)[source]¶ Remove current Docker container
- Parameters
force (
bool
, optional) – ifTrue
, force removal of the container (e.g. remove container even if it is running)
-
remove_containers
(force=False)[source]¶ Remove Docker all containers that are WC modeling environments
- Parameters
force (
bool
, optional) – ifTrue
, force removal of the container (e.g. remove containers even if they are running)
-
remove_image
(image_repo, image_tags, force=False)[source]¶ Remove version of Docker image
- Parameters
image_repo (
str
) – image repositoryimage_tags (
list
ofstr
) – list of tagsforce (
bool
, optional) – ifTrue
, force removal of the version of the image (e.g. even if a container with the image is running)
-
run_process_in_container
(cmd, work_dir=None, env=None, check=True, container_user=<WcEnvUser.root: 0>)[source]¶ Run a process in the current Docker container
- Parameters
cmd (
list
ofstr
orstr
) – command to runwork_dir (
str
, optional) – path to working directory within containerenv (
dict
, optional) – key/value pairs of environment variablescheck (
bool
, optional) – ifTrue
, raise exception if exit code is not 0container_user (
WcEnvUser
, optional) – user to run commands in container
- Returns
output of the process
- Return type
str
- Raises
WcEnvManagerError – if the command is not executed successfully
-
run_process_on_host
(cmd)[source]¶ Run a process on the host
- Parameters
cmd (
list
ofstr
orstr
) – command to run
-
set_container
(container)[source]¶ Set the Docker containaer
- Parameters
container (
docker.models.containers.Container
orstr
) – Docker container or name of Docker container
-
set_image
(image_repo, image)[source]¶ Set the Docker image for WC modeling environment
- Parameters
image_repo (
str
) – image repositoryimage (
docker.models.images.Image
orstr
) – Docker image or name of Docker image
-