Commit d95ec699 authored by David Trudgian's avatar David Trudgian
Browse files

Minor fixes

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