Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding in environmental variable to pkg_test #222

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8b99ff2
adding in environmental variable to pkg_test
jerowe Nov 16, 2017
181ff9e
commit
jerowe Nov 16, 2017
987fcf5
pushing change
jerowe Nov 17, 2017
b3b1b6f
pushing some debug commands
jerowe Nov 18, 2017
3320ddc
commiting
jerowe Nov 18, 2017
a0135f1
commiting
jerowe Nov 19, 2017
d345166
removing debug statements
jerowe Nov 19, 2017
ec19474
putting upload back the way it was
jerowe Nov 19, 2017
fb4170d
might have changed it to command line parameter
jerowe Nov 19, 2017
ef56c97
few debug statements
jerowe Nov 19, 2017
3a56a20
added in one debug statement
jerowe Nov 19, 2017
93d765a
Merge branch 'master' of https://github.com/bioconda/bioconda-utils i…
jerowe Nov 19, 2017
dca0cd5
fixing debug statement
jerowe Nov 20, 2017
004a309
ok now fixed
jerowe Nov 20, 2017
5b74249
trying to add in channels to pkg_test
jerowe Dec 6, 2017
5d0d474
Merge branch 'master' into develop
jerowe Dec 7, 2017
30b4382
channels should not be none
jerowe Dec 7, 2017
a78cc63
Merge branch 'develop' of github.com:jerowe/bioconda-utils into develop
jerowe Dec 7, 2017
b8d4b4c
fixe indentation
jerowe Dec 7, 2017
dfd87fb
adding to develop
jerowe Dec 8, 2017
9e1c42c
trying ot add in container pkg cache
jerowe Dec 8, 2017
3490b16
commit
jerowe Dec 8, 2017
552b5e1
try again
jerowe Dec 9, 2017
00e4200
trying it with a conda pkg dir
jerowe Dec 9, 2017
dce3746
this should not be none
jerowe Dec 11, 2017
a91a5f3
mulled_upload_target must have a target
jerowe Dec 11, 2017
93683e3
cleaned up docs
jerowe Dec 11, 2017
3b3907c
fixing package cache
jerowe Dec 11, 2017
99e9418
got the last one
jerowe Dec 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions bioconda_utils/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def build(
force=False,
channels=None,
docker_builder=None,
mulled_upload_target='biocontainers',
):
"""
Build a single recipe for a single env
Expand Down Expand Up @@ -66,6 +67,10 @@ def build(
docker_builder : docker_utils.RecipeBuilder object
Use this docker builder to build the recipe, copying over the built
recipe to the host's conda-bld directory.

mulled_upload_target: biocontainers
Namespace for docker container

"""

# Clean provided env and exisiting os.environ to only allow whitelisted env
Expand Down Expand Up @@ -161,7 +166,10 @@ def build(
base_image = 'bioconda/extended-base-image' if use_base_image else None

try:
res = pkg_test.test_package(pkg_path, base_image=base_image)
if channels:
res = pkg_test.test_package(pkg_path, base_image=base_image, mulled_upload_target=mulled_upload_target, channels=channels)
else:
res = pkg_test.test_package(pkg_path, base_image=base_image, mulled_upload_target=mulled_upload_target)

logger.info("TEST SUCCESS %s, %s", recipe, utils.envstr(_env))
mulled_image = pkg_test.get_image_name(pkg_path)
Expand All @@ -181,7 +189,7 @@ def build_recipes(
docker_builder=None,
label=None,
anaconda_upload=False,
mulled_upload_target=None,
mulled_upload_target='biocontainers',
check_channels=None,
):
"""
Expand Down Expand Up @@ -222,7 +230,7 @@ def build_recipes(
anaconda_upload : bool
If True, upload the package to anaconda.org.

mulled_upload_target : None
mulled_upload_target : biocontainers
If not None, upload the mulled docker image to the given target on quay.io.

check_channels : list
Expand Down Expand Up @@ -350,6 +358,7 @@ def build_recipes(
force=force,
channels=config['channels'],
docker_builder=docker_builder,
mulled_upload_target=mulled_upload_target,
)

all_success &= res.success
Expand Down
2 changes: 1 addition & 1 deletion bioconda_utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def build(
build_script_template=None,
pkg_dir=None,
anaconda_upload=False,
mulled_upload_target=None,
mulled_upload_target='biocontainers',
keep_image=False,
):
setup_logger(loglevel)
Expand Down
22 changes: 18 additions & 4 deletions bioconda_utils/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@
# exists before adding the channel.
mkdir -p {self.container_staging}/linux-64
mkdir -p {self.container_staging}/noarch
mkdir -p {self.container_package_cache}
conda config --add channels file://{self.container_staging} > /dev/null 2>&1
export CONDA_PKGS_DIRS={self.container_package_cache}

# The actual building...
# we explicitly point to the meta.yaml, in order to keep
Expand Down Expand Up @@ -192,6 +194,7 @@ def __init__(
tag='tmp-bioconda-builder',
container_recipe='/opt/recipe',
container_staging="/opt/host-conda-bld",
container_package_cache="/opt/anaconda-pkg-cache",
requirements=None,
build_script_template=BUILD_SCRIPT_TEMPLATE,
dockerfile_template=DOCKERFILE_TEMPLATE,
Expand Down Expand Up @@ -219,6 +222,9 @@ def __init__(
Upon successful building container-built packages will be copied
over. Mounted as read-write.

container_package_cache: str
If you are using package caches put them here

requirements : None or str
Path to a "requirements.txt" file which will be installed with
conda in a newly-created container. If None, then use the default
Expand Down Expand Up @@ -322,6 +328,8 @@ def __init__(

self.container_recipe = container_recipe
self.container_staging = container_staging
##TODO Clean this up - should get it from the environmental variable
self.container_package_cache = container_package_cache
self.host_conda_bld = get_host_conda_bld()

if use_host_conda_bld:
Expand Down Expand Up @@ -450,14 +458,20 @@ def build_recipe(self, recipe_dir, build_args, env, pkg, noarch=False):
env_list.append('-e')
env_list.append('{0}={1}'.format(k, v))

volume_mounts = [
'-v', '{0}:/opt/build_script.bash'.format(build_script),
'-v', '{0}:{1}'.format(self.pkg_dir, self.container_staging),
'-v', '{0}:{1}'.format(recipe_dir, self.container_recipe),
]

if os.environ.get('CONDA_PKGS_DIRS'):
volume_mounts = volume_mounts + ['-v', '{0}:{1}'.format(os.environ.get('CONDA_PKGS_DIRS'), self.container_package_cache)]

cmd = [
'docker', 'run',
'--net', 'host',
'--rm',
'-v', '{0}:/opt/build_script.bash'.format(build_script),
'-v', '{0}:{1}'.format(self.pkg_dir, self.container_staging),
'-v', '{0}:{1}'.format(recipe_dir, self.container_recipe),
] + env_list + [
] + volume_mounts + env_list + [
self.tag,
'/bin/bash', '/opt/build_script.bash',
]
Expand Down
9 changes: 7 additions & 2 deletions bioconda_utils/pkg_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def test_package(
name_override=None,
channels=["conda-forge", "defaults"],
mulled_args="",
base_image=None
base_image=None,
mulled_upload_target='biocontainers'
):
"""
Tests a built package in a minimal docker container.
Expand All @@ -104,6 +105,9 @@ def test_package(
base_image : None | str
Specify custom base image. Busybox is used in the default case.

mulled_upload_target : biocontainers | str
Namespace for docker container

"""

assert path.endswith('.tar.bz2'), "Unrecognized path {0}".format(path)
Expand All @@ -130,9 +134,10 @@ def test_package(
'mulled-build',
'build-and-test',
spec,
'-n', 'biocontainers',
'-n', mulled_upload_target,
'--test', tests
]
logger.debug('Cmd to run: %s' % cmd)
if name_override:
cmd += ['--name-override', name_override]
cmd += channel_args
Expand Down