Commit 7880d080 authored by Lukas Weber's avatar Lukas Weber
Browse files

support slow pyyaml again

parent d2ba8249
......@@ -3,6 +3,11 @@ import os
import subprocess
import errno
from yaml import CSafeLoader as SafeLoader
except ImportError:
from yaml import SafeLoader
'''Helpers for handling loadleveller jobfiles/scripts. For lack of a better idea, the job description files of loadleveller are actually executables that output a more verbose yaml parameter file to stdout. Use the taskmaker module to write the input scripts.'''
class JobFileGenError(Exception):
......@@ -19,7 +24,7 @@ class JobFile:
raise JobFileGenError('Generation script "{}" had a non-zero return code. Treating as error.'.format(filename))
parsed_job = yaml.load(self.raw_jobfile, Loader=yaml.CSafeLoader)
parsed_job = yaml.load(self.raw_jobfile, Loader=SafeLoader)
except Exception as e:
raise JobFileGenError('Could not parse job generation script output: {}'.format(e))
......@@ -2,6 +2,11 @@ import yaml
import numpy as np
import itertools
from yaml import CSafeLoader as SafeLoader
except ImportError:
from yaml import SafeLoader
'''This module can be used to easily extract Monte Carlo results from the *.results.yml file produced by the loadleveller library.'''
class Observable:
......@@ -16,7 +21,7 @@ class Observable:
class MCArchive:
def __init__(self, filename):
with open(filename, 'r') as f:
doc = yaml.load(f, Loader=yaml.CSafeLoader)
doc = yaml.load(f, Loader=SafeLoader)
param_names = set(sum([list(task['parameters'].keys()) for task in doc], []))
observable_names = set(sum([list(task['results'].keys()) for task in doc], []))
......@@ -3,12 +3,17 @@ import os
import yaml
import numpy
from yaml import CSafeLoader as SafeLoader, CSafeDumper as SafeDumper
except ImportError:
from yaml import SafeLoader, SafeDumper
def _expand_path(path):
return os.path.abspath(os.path.expandvars(os.path.expanduser(path)))
def JobConfig(filename):
with open(_expand_path(filename), 'r') as f:
return yaml.load(f, Loader=yaml.CSafeLoader)
return yaml.load(f, Loader=SafeLoader)
class TaskMaker:
def __init__(self, name, jobconfig):
......@@ -41,4 +46,4 @@ class TaskMaker:
task_dict[k] = v
jobfile_dict['tasks'][task_name] = task_dict
print(yaml.dump(jobfile_dict, Dumper=yaml.CSafeDumper))
print(yaml.dump(jobfile_dict, Dumper=SafeDumper))
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