Skip to content

Commit

Permalink
Allow data installs without Docker images present
Browse files Browse the repository at this point in the history
Makes managing data from bcbio_vm.py easier. Thanks to discussion in
bcbio/bcbio-nextgen#2473
  • Loading branch information
chapmanb committed Nov 27, 2018
1 parent 9fb1965 commit 6c858cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
24 changes: 18 additions & 6 deletions bcbiovm/docker/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,19 @@ def full(args, dockerconf):
sys.exit(1)
else:
updates.append("biological data")
_check_docker_image(args)
manage.run_bcbio_cmd(args.image, dmounts, _get_cl(args))
if _check_docker_image(args, raise_error=False):
manage.run_bcbio_cmd(args.image, dmounts, _get_cl(args))
else:
args.upgrade = False
args.tools = False
args.tooldir = False
args.toolplus = False
args.isolate = True
args.distribution = None
args.cwl = True
print(args)
from bcbio import install
install.upgrade_bcbio(args)
_save_install_defaults(args)
if updates:
print("\nbcbio-nextgen-vm updated with latest %s" % " and ".join(updates))
Expand Down Expand Up @@ -66,7 +77,7 @@ def upgrade_bcbio_vm():
else:
subprocess.check_call([conda_bin, "install", "-y", "-c", "conda-forge", "-c", "bioconda",
"bcbio-nextgen-vm", "bcbio-nextgen", "cwltool", "arvados-cwl-runner",
"toil", "rabix-bunny"])
"toil", "cromwell"])

def pull(args, dockerconf):
"""Pull down latest docker image.
Expand Down Expand Up @@ -126,14 +137,15 @@ def add_install_defaults(args):
args = _add_docker_defaults(args, default_args)
return args

def _check_docker_image(args):
def _check_docker_image(args, raise_error=True):
"""Ensure docker image exists.
"""
for image in subprocess.check_output(["docker", "images"]).split("\n"):
parts = image.split()
if len(parts) > 1 and parts[0] == args.image:
return
raise ValueError("Could not find docker image %s in local repository" % args.image)
return True
if raise_error:
raise ValueError("Could not find docker image %s in local repository" % args.image)

def docker_image_arg(args):
if not hasattr(args, "image") or not args.image:
Expand Down
1 change: 1 addition & 0 deletions scripts/bcbio_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def _install_cmd(subparsers, name):
action="store_true", default=False)
parser_i.add_argument("--image", help="Docker image name to use, could point to compatible pre-installed image.",
default=None)
parser_i.add_argument("--cores", help="Cores to use for parallel data prep processes", default=1, type=int)
parser_i.set_defaults(func=cmd_install)

def _std_config_args(parser):
Expand Down

0 comments on commit 6c858cf

Please sign in to comment.