Commit ebb46855 authored by Lukas Weber's avatar Lukas Weber
Browse files

some python fixes

parent ca492e4e
import tempfile
import os
import sys
batchscript_claix18 = '''
#!/usr/bin/env zsh
......@@ -17,7 +18,7 @@ batchscript_claix18 = '''
{custom_cmds}
$MPIEXEC $FLAGS_MPI_BATCH {cmd}
{mpirun} $FLAGS_MPI_BATCH {cmd}
'''
batchscript_templates = {
......@@ -31,15 +32,21 @@ batch_commands = {
valid_systems = ['local', 'claix18']
def generate_batchscript(template, cmd, jobname, jobconfig):
return template.format(
jobname=jobname,
mem_per_cpu=jobconfig['mem_per_cpu'],
walltime=jobconfig['walltime'],
project=jobconfig['project'],
num_cores=jobconfig['num_cores'],
custom_cmds=jobconfig['custom_cmds'],
mc_cmd=' '.join(cmd)
)
try:
return template.format(
jobname=jobname,
mpirun=jobconfig.get('mpirun','mpirun'),
mem_per_cpu=jobconfig.get('mem_per_cpu','2G'),
walltime=jobconfig['mc_walltime'],
project=jobconfig.get('project',''),
num_cores=jobconfig['num_cores'],
custom_cmds=jobconfig.get('custom_cmds',''),
mc_cmd=' '.join(cmd)
)
except KeyError as e:
print('Error: required key "{}" missing in jobconfig'.format(e.args[0]))
sys.exit(1)
def determine_system():
sysinfo = os.environ.get('MCLL_SYSTEM_INFO')
......
......@@ -3,12 +3,12 @@
import yaml
import argparse
import subprocess
from loadleveller import clusterutils
from safeloadleveller import clusterutils
import glob
import sys
import os
parser = argparse.ArgumentParser(description='This helper program runs a loadleveller Monte Carlo program using a provided YAML-formatted jobfile. The jobfile contains information on how to run the job (what mc binary, mpi-parameters, ...) and a number of tasks with different simulation parameters each. When running on a cluster batch system, the batch script is generated using ygeneratebatchscript.')
parser = argparse.ArgumentParser(description='This helper program runs a safeloadleveller Monte Carlo program using a provided YAML-formatted jobfile. The jobfile contains information on how to run the job (what mc binary, mpi-parameters, ...) and a number of tasks with different simulation parameters each. When running on a cluster batch system, the batch script is generated using ygeneratebatchscript.')
parser.add_argument('jobfile', metavar='JOBFILE', help='Configuration file containing all the job information. May be generated using ytaskmaker')
parser.add_argument('-s','--single', action='store_true', help='Run in the single core scheduler mode')
......@@ -28,11 +28,11 @@ if args.single and args.merge:
sys.exit(1)
with open(jobfile_name, 'r') as f:
jobfile = yaml.load(f)
jobfile = yaml.safeload(f)
jobconfig_path = os.path.expandvars(os.path.expanduser(jobfile['jobconfig']))
with open(jobconfig_path) as f:
jobconfig = yaml.load(f)
jobconfig = yaml.safeload(f)
mcbinary = os.path.expandvars(os.path.expanduser(jobconfig['mc_binary']))
......
......@@ -46,7 +46,7 @@ results merge(const std::vector<std::string> &filenames, const std::vector<evala
continue;
}
if(res.observables.count(obs_name) == 0)
if(res.observables.count(obs_name) == 0)
res.observables.emplace(obs_name, observable_result());
auto &obs = res.observables.at(obs_name);
obs.name = obs_name;
......
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