Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #84 from galaxyproject/tripple
Browse files Browse the repository at this point in the history
make multitool-container generation a little bit more stable
  • Loading branch information
jmchilton committed Nov 23, 2017
2 parents 73e35b1 + e067e01 commit 9470e3a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
6 changes: 3 additions & 3 deletions galaxy/tools/deps/mulled/invfile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ end

local conda_image = VAR.CONDA_IMAGE
if conda_image == '' then
conda_image = 'continuumio/miniconda:latest'
conda_image = 'continuumio/miniconda3:latest'
end


Expand Down Expand Up @@ -104,8 +104,8 @@ if VAR.SINGULARITY ~= '' then
.withHostConfig({binds = {"build:/data",singularity_image_dir .. ":/import"}, privileged = true})
.withConfig({entrypoint = {'/bin/sh', '-c'}})
-- for small containers (less than 7MB), double the size otherwise, add a little bit more as half the conda size
.run("size=$(du -sc /data/dist/ | tail -n 1 | cut -f 1 | awk '{print int($1/1024)}' ) && if [ $size -lt '7' ]; then echo $(($size*2)); else echo $(($size+$size*7/10)); fi")
.run("singularity create --size `size=$(du -sc /data/dist/ | tail -n 1 | cut -f 1 | awk '{print int($1/1024)}' ) && if [ $size -lt '7' ]; then echo $(($size*2)); else echo $(($size+$size*7/10)); fi` /import/" .. VAR.SINGULARITY_IMAGE_NAME)
.run("size=$(du -sc /data/dist/ | tail -n 1 | cut -f 1 | awk '{print int($1/1024)}' ) && if [ $size -lt '10' ]; then echo 20; else echo $(($size+$size*7/10)); fi")
.run("singularity create --size `size=$(du -sc /data/dist/ | tail -n 1 | cut -f 1 | awk '{print int($1/1024)}' ) && if [ $size -lt '10' ]; then echo 20; else echo $(($size+$size*7/10)); fi` /import/" .. VAR.SINGULARITY_IMAGE_NAME)
.run('mkdir -p /usr/local/var/singularity/mnt/container && singularity bootstrap /import/' .. VAR.SINGULARITY_IMAGE_NAME .. ' /import/Singularity')
.run('chown ' .. VAR.USER_ID .. ' /import/' .. VAR.SINGULARITY_IMAGE_NAME)
end
Expand Down
6 changes: 4 additions & 2 deletions galaxy/tools/deps/mulled/mulled_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@
conda_build_target_str,
create_repository,
quay_repository,
PrintProgress,
v1_image_name,
v2_image_name,
)
from ..conda_compat import MetaData

DIRNAME = os.path.dirname(__file__)
DEFAULT_CHANNEL = "bioconda"
DEFAULT_EXTRA_CHANNELS = ["conda-forge", "r"]
DEFAULT_EXTRA_CHANNELS = ["conda-forge"]
DEFAULT_CHANNELS = [DEFAULT_CHANNEL] + DEFAULT_EXTRA_CHANNELS
DEFAULT_REPOSITORY_TEMPLATE = "quay.io/${namespace}/${image}"
DEFAULT_BINDS = ["build/dist:/usr/local/"]
Expand Down Expand Up @@ -242,7 +243,8 @@ def mull_targets(
with open(os.path.join(singularity_image_dir, 'Singularity'), 'w+') as sin_def:
fill_template = SINGULARITY_TEMPLATE % {'container_test': test}
sin_def.write(fill_template)
ret = involucro_context.exec_command(involucro_args)
with PrintProgress():
ret = involucro_context.exec_command(involucro_args)
if singularity:
# we can not remove this folder as it contains the image wich is owned by root
pass
Expand Down
6 changes: 5 additions & 1 deletion galaxy/tools/deps/mulled/mulled_build_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import collections
import glob
import os
import sys

from ._cli import arg_parser
from .mulled_build import (
Expand All @@ -36,14 +37,17 @@ def main(argv=None):
args = parser.parse_args()
for (targets, image_build, name_override) in generate_targets(args.files):
try:
mull_targets(
ret = mull_targets(
targets,
image_build=image_build,
name_override=name_override,
**args_to_mull_targets_kwds(args)
)
except BuildExistsException:
continue
if ret > 0:
sys.exit(ret)



def generate_targets(target_source):
Expand Down
24 changes: 24 additions & 0 deletions galaxy/tools/deps/mulled/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

import collections
import hashlib
import time
import threading
import sys

from distutils.version import LooseVersion

Expand Down Expand Up @@ -207,6 +210,27 @@ def v2_image_name(targets, image_build=None, name_override=None):
return "mulled-v2-%s%s" % (package_hash.hexdigest(), suffix)


class PrintProgress:
def __init__(self):
self.thread = threading.Thread(target=self.progress)
self.stop = False

def progress(self):
while not self.stop:
print(".", end="")
sys.stdout.flush()
time.sleep(60)
print("")

def __enter__(self):
self.thread.start()
return self

def __exit__(self, exc_type, exc_val, exc_tb):
self.stop = True
self.thread.join()


image_name = v1_image_name # deprecated

__all__ = (
Expand Down

0 comments on commit 9470e3a

Please sign in to comment.