Commit e2118a2f authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

MNT: Add hack to skip large packages, and speed up test (and hopefully not

kill my home internet)
parent 019559ad
#!/usr/bin/env python
__version__ = '0.7.3'
__version__ = '0.7.4'
......@@ -4,6 +4,9 @@
# the number of output lines produced when installing miniconda, and
# when installing the FSL environment.
# When a full test is perforemd, the SKIP_PACKAGES environment variable can be
# used to skip specific packages (e.g. if they are particularly large). It
# can be set to a space-separated list of package names to be skipped.
import os.path as op
......@@ -76,7 +79,7 @@ def fast_test(envfile, release_info):
return install_out, env_out
def full_test(envfile, release_info):
def full_test(envfile, release_info, skip_pkgs):
platform = parse_environment_file_name(envfile)[1]
miniconda_url = release_info['miniconda'][platform]
......@@ -89,13 +92,25 @@ def full_test(envfile, release_info):
preprocess_environment(envfile, 'fsl', True)
skipped = []
basepkgs = {}
with open(envfile, 'rt') as f:
with open(envfile, 'rt') as f, open(envfile + '.copy', 'wt') as outf:
for line in f:
# get base package versions
for pkg in base_packages:
if line.strip().startswith(f'- {pkg} '):
pkgver = line.strip().split(maxsplit=2)[2]
basepkgs[pkg] = pkgver.replace(' ', '=')
skip = False
if line.strip().startswith('-'):
pkg = line.strip().split()[1]
if pkg in skip_pkgs:
skip = True
print(f'Skipping package (matched {pattern}): {pkg}')
if not skip:
env = os.environ.copy()
env['CONDARC'] = op.abspath(op.join('fsl', 'condarc'))
......@@ -108,9 +123,13 @@ def full_test(envfile, release_info):
env_out = sprun(f'./fsl/bin/conda install -y -n base {basepkgs}',
env_out += sprun(f'./fsl/bin/conda env update -n base -f {envfile}',
env_out += sprun(f'./fsl/bin/conda env update -n base -f {envfile}.copy',
# Add an output line for each skipped package,
# so the line count is still accurate
env_out += '\n'.join(skipped)
return install_out, env_out
......@@ -138,6 +157,12 @@ def main():
username = os.environ.get('FSLCONDA_USERNAME', 'username')
password = os.environ.get('FSLCONDA_PASSWORD', 'password')
# space-separated list of package names
# to be skipped for the test (full test
# only)
skip_pkgs = os.environ.get('SKIP_PACKAGES', '')
skip_pkgs = skip_pkgs.split(' ')
with tempdir():
shutil.copy(envfile, '.environment.yml')
......@@ -150,7 +175,7 @@ def main():
if run_full_test:
install_out, env_out = full_test(envfile, release_info)
install_out, env_out = full_test(envfile, release_info, skip_pkgs)
install_out, env_out = fast_test(envfile, release_info)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment