Merge pull request #2255 from jtkrogel/nx_render_bool

Nexus: harden boolean rendering
This commit is contained in:
Ye Luo 2020-01-29 12:50:26 +08:00 committed by GitHub
commit 0d06cee574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 42 deletions

View File

@ -127,8 +127,8 @@ class Options(DevBase):
def write(self):
s = ''
for o in self:
s += ' '+str(o)
for k in sorted(self.keys()):
s += ' '+str(self[k])
#end for
return s
#end def write
@ -1492,11 +1492,11 @@ class Supercomputer(Machine):
self.error('failed to set env options for runjob')
#end if
job.run_options.add(
np = '--np '+str(job.processes),
p = '-p '+str(job.processes_per_node),
locargs = '$LOCARGS',
verbose = '--verbose=INFO',
envs = envs
np = '--np '+str(job.processes),
p = '-p '+str(job.processes_per_node),
xlocargs = '$LOCARGS',
verbose = '--verbose=INFO',
envs = envs
)
elif launcher=='srun': # Amos contribution from Ryan McAvoy
None # anything needed here?

View File

@ -210,11 +210,7 @@ def attribute_to_value(attr):
#local write types
def yesno(var):
if var:
return 'yes'
else:
return 'no'
#end if
return render_bool(var,'yes','no')
#end def yesno
def yesnostr(var):
@ -226,21 +222,29 @@ def yesnostr(var):
#end def yesnostr
def onezero(var):
if var:
return '1'
else:
return '0'
#end if
return render_bool(var,'1','0')
#end def onezero
def truefalse(var):
if var:
return 'true'
else:
return 'false'
#end if
return render_bool(var,'true','false')
#end def onezero
def render_bool(var,T,F):
if isinstance(var,bool) or var in (1,0):
if var:
return T
else:
return F
#end if
elif var in (T,F):
return var
else:
error('Invalid QMCPACK input encountered.\nUser provided an invalid value of "{}" when yes/no was expected.\nValid options are: "{}", "{}", True, False, 1, 0'.format(var,T,F))
#end if
#end def render_bool
bool_write_types = set([yesno,onezero,truefalse])

View File

@ -81,7 +81,7 @@
<parameter name="steps" > 10 </parameter>
<parameter name="timestep" > 0.005 </parameter>
<parameter name="nonlocalmoves" > yes </parameter>
<parameter name="reconfiguration" > yes </parameter>
<parameter name="reconfiguration" > no </parameter>
<parameter name="minimumtargetwalkers"> 128 </parameter>
</qmc>
</simulation>

View File

@ -83,7 +83,7 @@
<parameter name="steps" > 10 </parameter>
<parameter name="timestep" > 0.005 </parameter>
<parameter name="nonlocalmoves" > yes </parameter>
<parameter name="reconfiguration" > yes </parameter>
<parameter name="reconfiguration" > no </parameter>
<parameter name="minimumtargetwalkers"> 128 </parameter>
</qmc>
</simulation>

View File

@ -1051,12 +1051,12 @@ def test_job_run_command():
('cades_moab' , 'n2_t2' ) : 'mpirun --npersocket 9 -np 36 test.x',
('cades_moab' , 'n2_t2_e' ) : 'mpirun --npersocket 9 -np 36 test.x',
('cades_moab' , 'n2_t2_p2' ) : 'mpirun --npersocket 1 -np 4 test.x',
('cetus' , 'n1' ) : 'runjob --np 16 -p 16 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=1 : test.x',
('cetus' , 'n1_p1' ) : 'runjob --np 1 -p 1 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=1 : test.x',
('cetus' , 'n2' ) : 'runjob --np 32 -p 16 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=1 : test.x',
('cetus' , 'n2_t2' ) : 'runjob --np 16 -p 8 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=2 : test.x',
('cetus' , 'n2_t2_e' ) : 'runjob --np 16 -p 8 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=2 ENV_VAR=1 : test.x',
('cetus' , 'n2_t2_p2' ) : 'runjob --np 4 -p 2 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=2 : test.x',
('cetus' , 'n1' ) : 'runjob --envs OMP_NUM_THREADS=1 --np 16 -p 16 --verbose=INFO $LOCARGS : test.x',
('cetus' , 'n1_p1' ) : 'runjob --envs OMP_NUM_THREADS=1 --np 1 -p 1 --verbose=INFO $LOCARGS : test.x',
('cetus' , 'n2' ) : 'runjob --envs OMP_NUM_THREADS=1 --np 32 -p 16 --verbose=INFO $LOCARGS : test.x',
('cetus' , 'n2_t2' ) : 'runjob --envs OMP_NUM_THREADS=2 --np 16 -p 8 --verbose=INFO $LOCARGS : test.x',
('cetus' , 'n2_t2_e' ) : 'runjob --envs OMP_NUM_THREADS=2 ENV_VAR=1 --np 16 -p 8 --verbose=INFO $LOCARGS : test.x',
('cetus' , 'n2_t2_p2' ) : 'runjob --envs OMP_NUM_THREADS=2 --np 4 -p 2 --verbose=INFO $LOCARGS : test.x',
('chama' , 'n1' ) : 'srun test.x',
('chama' , 'n1_p1' ) : 'srun test.x',
('chama' , 'n2' ) : 'srun test.x',
@ -1117,12 +1117,12 @@ def test_job_run_command():
('matisse' , 'n2_t2' ) : 'mpirun -np 16 test.x',
('matisse' , 'n2_t2_e' ) : 'mpirun -np 16 test.x',
('matisse' , 'n2_t2_p2' ) : 'mpirun -np 4 test.x',
('mira' , 'n1' ) : 'runjob --np 16 -p 16 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=1 : test.x',
('mira' , 'n1_p1' ) : 'runjob --np 1 -p 1 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=1 : test.x',
('mira' , 'n2' ) : 'runjob --np 32 -p 16 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=1 : test.x',
('mira' , 'n2_t2' ) : 'runjob --np 16 -p 8 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=2 : test.x',
('mira' , 'n2_t2_e' ) : 'runjob --np 16 -p 8 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=2 ENV_VAR=1 : test.x',
('mira' , 'n2_t2_p2' ) : 'runjob --np 4 -p 2 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=2 : test.x',
('mira' , 'n1' ) : 'runjob --envs OMP_NUM_THREADS=1 --np 16 -p 16 --verbose=INFO $LOCARGS : test.x',
('mira' , 'n1_p1' ) : 'runjob --envs OMP_NUM_THREADS=1 --np 1 -p 1 --verbose=INFO $LOCARGS : test.x',
('mira' , 'n2' ) : 'runjob --envs OMP_NUM_THREADS=1 --np 32 -p 16 --verbose=INFO $LOCARGS : test.x',
('mira' , 'n2_t2' ) : 'runjob --envs OMP_NUM_THREADS=2 --np 16 -p 8 --verbose=INFO $LOCARGS : test.x',
('mira' , 'n2_t2_e' ) : 'runjob --envs OMP_NUM_THREADS=2 ENV_VAR=1 --np 16 -p 8 --verbose=INFO $LOCARGS : test.x',
('mira' , 'n2_t2_p2' ) : 'runjob --envs OMP_NUM_THREADS=2 --np 4 -p 2 --verbose=INFO $LOCARGS : test.x',
('oic5' , 'n1' ) : 'mpirun -np 32 test.x',
('oic5' , 'n1_p1' ) : 'mpirun -np 1 test.x',
('oic5' , 'n2' ) : 'mpirun -np 64 test.x',
@ -1215,12 +1215,12 @@ def test_job_run_command():
('uno' , 'n2_t2' ) : 'srun test.x',
('uno' , 'n2_t2_e' ) : 'srun test.x',
('uno' , 'n2_t2_p2' ) : 'srun test.x',
('vesta' , 'n1' ) : 'runjob --np 16 -p 16 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=1 : test.x',
('vesta' , 'n1_p1' ) : 'runjob --np 1 -p 1 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=1 : test.x',
('vesta' , 'n2' ) : 'runjob --np 32 -p 16 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=1 : test.x',
('vesta' , 'n2_t2' ) : 'runjob --np 16 -p 8 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=2 : test.x',
('vesta' , 'n2_t2_e' ) : 'runjob --np 16 -p 8 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=2 ENV_VAR=1 : test.x',
('vesta' , 'n2_t2_p2' ) : 'runjob --np 4 -p 2 $LOCARGS --verbose=INFO --envs OMP_NUM_THREADS=2 : test.x',
('vesta' , 'n1' ) : 'runjob --envs OMP_NUM_THREADS=1 --np 16 -p 16 --verbose=INFO $LOCARGS : test.x',
('vesta' , 'n1_p1' ) : 'runjob --envs OMP_NUM_THREADS=1 --np 1 -p 1 --verbose=INFO $LOCARGS : test.x',
('vesta' , 'n2' ) : 'runjob --envs OMP_NUM_THREADS=1 --np 32 -p 16 --verbose=INFO $LOCARGS : test.x',
('vesta' , 'n2_t2' ) : 'runjob --envs OMP_NUM_THREADS=2 --np 16 -p 8 --verbose=INFO $LOCARGS : test.x',
('vesta' , 'n2_t2_e' ) : 'runjob --envs OMP_NUM_THREADS=2 ENV_VAR=1 --np 16 -p 8 --verbose=INFO $LOCARGS : test.x',
('vesta' , 'n2_t2_p2' ) : 'runjob --envs OMP_NUM_THREADS=2 --np 4 -p 2 --verbose=INFO $LOCARGS : test.x',
})
if testing.global_data['job_ref_table']: