Commit 625083ab authored by Lukas Weber's avatar Lukas Weber
Browse files

refactor ystatus

parent fec2e0be
......@@ -9,6 +9,11 @@ setuptools.setup(
url="https://git.rwth-aachen.de/lukas.weber2/load_leveller",
packages=setuptools.find_packages(),
license="MIT",
scripts=["ydelete","yrun","ystatus"],
install_requires=["pyyaml","h5py","numpy"]
scripts=["ydelete","yrun"],
install_requires=["pyyaml","h5py","numpy"],
entry_points={
'console_scripts': [
'ystatus = loadleveller.jobstatus:ystatus',
],
}
)
#!/usr/bin/env python3
import argparse
import glob
import h5py
import os
import yaml
parser = argparse.ArgumentParser(description='Prints the status and progress of a loadleveller Monte Carlo job.')
parser.add_argument('jobfile', metavar='JOBFILE', help='Configuration file containing all the job information.')
args = parser.parse_args()
with open(args.jobfile, 'r') as f:
jobfile = yaml.load(f)
tasks = jobfile['tasks'].keys()
needs_restart = False
needs_merge = False
result_mtime = 0
try:
result_mtime = os.path.getmtime(args.jobfile+'.results.yml')
except(FileNotFoundError):
pass
for task in tasks:
target_sweeps = jobfile['tasks'][task]['sweeps']
target_therm = jobfile['tasks'][task]['thermalization']
sweeps = 0
therm_sweeps = 0
num_runs = 0
for runfile in glob.iglob('{}.data/{}/run*.dump.h5'.format(args.jobfile,task)):
num_runs += 1
with h5py.File(runfile, 'r') as f:
sweeps += f['/sweeps'][0]
therm_sweeps += f['/thermalization_sweeps'][0]
for measfile in glob.iglob('{}.data/{}/run*.meas.h5'.format(args.jobfile,task)):
if os.path.getmtime(measfile) > result_mtime:
needs_merge = True
if sweeps < target_sweeps + target_therm:
needs_restart = True
print('{}: {} runs, {}/{} sweeps, {}/{} thermalization'.format(task, num_runs, sweeps-therm_sweeps, target_sweeps, therm_sweeps, target_therm))
if needs_restart:
print('\nNeeds restart!')
if needs_merge:
print('\nNeeds merge! (run \'yrun -m {0}\' to get an up-to-date {0}.results.yml file)'.format(args.jobfile))
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