Commit 4ea337a6 authored by David Trudgian's avatar David Trudgian
Browse files

Have some basic integration testing on at least local executor

parent 96069ca4
......@@ -4,4 +4,4 @@ before_script:
test:
script:
- source .venv/bin/activate
- python setup.py test
- pytest --cov=param_runner test/
......@@ -45,6 +45,7 @@ class ParamFile(object):
params = OrderedDict()
combination_count = None
commands = []
loaded = False
mypath = os.path.dirname(os.path.abspath(__file__))
......@@ -117,6 +118,10 @@ class ParamFile(object):
def load(self):
"""Read in metadata from the astrocyte_pkg.yml to populate vals dict"""
if self.loaded:
raise ParamFileException("Parameter information was already loaded.")
self.validate()
metadata = anyconfig.load(self.param_file)
self.vals = metadata
......@@ -124,6 +129,7 @@ class ParamFile(object):
self.__check_summary_regexes()
self.__compute_param_ranges()
self.commands = self.__compute_commands()
self.loaded = True
def __check_summary_regexes(self):
......@@ -178,14 +184,15 @@ class ParamFile(object):
"""
if self.commands:
raise ParamFileException("Commands have already been computed")
logger.info("Computing Commands...")
arg_combns = self.__recurse_arg_combns()
arg_combns = self.__recurse_arg_combns(0, OrderedDict(), [])
logger.info(" - Computed %d argument combinations" % len(arg_combns))
assert len(arg_combns) == self.combination_count
cmd_arr = []
for arg_combn in arg_combns:
arg_combn['__command'] = { 'value': self.__cmd_from_args(arg_combn) }
......
import os
from glob import glob
import pytest
import shutil
from param_runner.param import ParamFile
from param_runner.executors import *
class TestExecutors:
@pytest.fixture(scope='session')
def test_dir(self, tmpdir_factory):
test_dir = tmpdir_factory.mktemp("param")
return str(test_dir)
@pytest.fixture(scope='session')
def param_yaml(self, test_dir):
test_param_source = os.path.dirname(
os.path.abspath(__file__)) + '/test_data/test_params.yaml'
shutil.copy(test_param_source, test_dir )
return os.path.join(test_dir, 'test_params.yaml')
@pytest.fixture(scope='session')
def param_file(self, param_yaml):
pf = ParamFile(param_yaml)
pf.load()
return pf
def test_local_executor(self, test_dir, param_file):
le = LocalExecutor(param_file.commands, test_dir, param_file)
le.run()
# There should be 170 error files (one per task)
err_files = glob(test_dir + '/param_runner*/*.err')
assert len(err_files) == 170
# All of the error files should be empty!
for err_file in err_files:
assert os.stat(err_file).st_size == 0
# There should be 170 output files (one per task)
out_files = glob(test_dir + '/param_runner*/*.out')
assert len(err_files) == 170
# There should be on trace.txt file
trace_files = glob(test_dir + '/param_runner*/trace.txt')
assert len(trace_files) == 1
# It should have 171 lines (header + 170 task summaries)
with open(trace_files[0]) as f:
for i, l in enumerate(f):
pass
assert i+1 == 171
Markdown is supported
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