Skip to content
Snippets Groups Projects
Commit 33c94ba6 authored by Yngve Levinsen's avatar Yngve Levinsen
Browse files

error study script

 - python3 prints
 - settings.yml is optional
 - clarifying question
parent 2a29e914
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
from __future__ import print_function
from ess import __queue_templates__
def define_and_handle_args():
......@@ -42,18 +43,22 @@ def create_and_copy_lattice(args, calc_dir, commented=[], extra_line=''):
'''
import yaml,shutil,os
# Create the lattice file from template:
lattice_settings=yaml.load(file(args.settings,'r').read())
lattice_settings['extra_line']=extra_line
if os.path.exists(args.settings):
# Create the lattice file from template:
lattice_settings=yaml.load(file(args.settings,'r').read())
lattice_settings['extra_line']=extra_line
lattice_template=file(args.lattice+'.tmp','r').read()
for cmd in commented:
lattice_template=lattice_template.replace(cmd.lower(),';'+cmd)
lattice_template=lattice_template.replace(cmd.upper(),';'+cmd)
lattice_template=file(args.lattice+'.tmp','r').read()
for cmd in commented:
lattice_template=lattice_template.replace(cmd.lower(),';'+cmd)
lattice_template=lattice_template.replace(cmd.upper(),';'+cmd)
file(calc_dir+'/'+args.lattice,'w').write(lattice_template.format(**lattice_settings))
file(os.path.join(calc_dir,args.lattice),'w').write(lattice_template.format(**lattice_settings))
shutil.copy(args.settings, calc_dir)
shutil.copy(args.settings, calc_dir)
else:
shutil.copy(args.lattice,os.path.join(calc_dir,args.lattice))
for folder in os.listdir(calc_dir):
if folder[0:15]=="Local_TraceWin_":
......@@ -100,7 +105,7 @@ def delete_output_files(args,folder):
def setup_multi(args):
import os
print "multi study.."
print("multi study..")
# the statistical study in TW to do, normally 14
stat_study=args.study+13
......@@ -151,7 +156,7 @@ def setup_multi(args):
if num_jobs==0:
raise ValueError("Could not find any simulation folders in "+args.calc_dir)
print "Total number of new jobs", num_jobs
print("Total number of new jobs", num_jobs)
args.num_jobs=num_jobs
def setup(args):
......@@ -207,10 +212,10 @@ def setup(args):
out.write(queue_template.format(**locals()))
def ask(args):
print "You have now set up an error study running {} jobs in folder {}".format(args.num_jobs,args.calc_dir)
print("You have now set up an error study running {} jobs in folder {}".format(args.num_jobs,args.calc_dir))
if args.multi>1:
print "This is a multi-error study"
answer=raw_input("Are you sure you want to continue? (yes/no)")
print("This is a multi-error study")
answer=raw_input("Do you want to submit the jobs immediately? (yes/no) ")
if answer=='yes':
return 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment