Skip to content
Snippets Groups Projects
Commit d95ec699 authored by David Trudgian's avatar David Trudgian
Browse files

Minor fixes

parent b2d54aa0
No related merge requests found
......@@ -32,7 +32,7 @@ class BaseExecutor:
logdir = os.path.join(cwd,
"param_runner_%s" % datetime.datetime.now().strftime(
'%Y%m%d-%H%M%s'))
'%Y%m%d-%H%M%S'))
try:
os.mkdir(logdir)
......@@ -146,7 +146,7 @@ class LocalExecutor(BaseExecutor):
class SrunExecutor(BaseExecutor):
def run(self):
if 'SLURM_JOB_CPUS_PER_NODE' not in os.environ:
if 'SLURM_JOB_ID' not in os.environ:
raise EnvironmentError(
'The srun executor can only be run inside a SLURM allocation.')
......
......@@ -4,9 +4,9 @@
command: echo train_ann --input train.set --crossk 10 TPF=0.01 FPF=0.13
# An optional workind directory. param_runner will cd to this directory
# An optional working directory. param_runner will cd to this directory
# before beginning to run commands.
work_dir: /tmp/param_work_test
#work_dir: /tmp/param_work_test
# The standard output from a command will be collected into a file named:
......
......@@ -4,10 +4,9 @@
command: echo train_ann --input train.set --crossk 10 TPF=0.01 FPF=0.13
# An optional workind directory. param_runner will cd to this directory
# An optional working directory. param_runner will cd to this directory
# before beginning to run commands.
work_dir: /tmp/param_work_test
#work_dir: /tmp/param_work_test
# The standard output from a command will be collected into a file named:
# out_<param1 val>_<param2 val>_<param3_val>.....out
......
import os
from glob import glob
import pytest
import shutil
......@@ -33,29 +32,28 @@ class TestExecutors:
le = LocalExecutor(param_file.commands, test_dir, param_file)
le.run()
if param_file.vals['work_dir']:
test_dir = param_file.vals['work_dir']
# There should be 1 log directory
log_dirs = glob(test_dir + '/param_runner*')
assert len(log_dirs) == 1
log_dir = log_dirs[0]
# There should be 170 error files (one per task)
err_files = glob(test_dir + '/param_runner*/*.err')
err_files = glob(log_dir + '/*.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')
out_files = glob(log_dir + '/*.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
trace_file = os.path.join(log_dir, 'trace.txt')
assert os.path.exists(trace_file)
# It should have 171 lines (header + 170 task summaries)
with open(trace_files[0]) as f:
with open(trace_file) as f:
for i, l in enumerate(f):
pass
assert i+1 == 171
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