The yade won't print anything until the python script is all finished in slurm command

Asked by JIPEIQI

Hi everyone! I'm using the HPC to run yade with the operation system of centos. You have to submit your job via the slurm [1] system. So here is the problem:
when you use "yade sth.py" command, it will print the information that you use "print "sth" " command in your python script line by line.
And in hpc, however you need to create another script like "a.sbatch" which writes:

#!/bin/bash
#SBATCH -c 8 -p hpxg -t 100
yade -j 8 gravity.py

Then you can type "sbatch a.sbatch" to submit your job. And when you do this, all printed informations will only show up when all of your python script is finished. I.e., for the gravity.py:

from yade import pack
import time
print 1
O.bodies.append(geom.facetBox((.5,.5,.5),(.5,.5,.5),wallMask=31))
sp=pack.SpherePack()
sp.makeCloud((0,0,0),(1,1,1),rMean=.01,rRelFuzz=.5)
sp.toSimulation()
print len(O.bodies)
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
 InteractionLoop([Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_FrictPhys()],
  [Law2_ScGeom_FrictPhys_CundallStrack()]
 ),
 NewtonIntegrator(gravity=(0,0,-9.81),damping=0.1),
 VTKRecorder(fileName='/data/pqji/yade-run/gravity-',recorders=['all'],label='vvtk',iterPeriod=200),
 PyRunner(command='checkUnbalanced()', iterPeriod=1000)
]
O.dt=.5*PWaveTimeStep()
print O.dt
def checkUnbalanced():
 print "unbalance force is %s" % unbalancedForce()
 if unbalancedForce()<.0001:
  print "Finish"
  O.pause()
O.run(wait=True) #
time.sleep(1) # I have to add this line so the slurm won't kill my job, as if this line is not added, the ipython line will show up and the slurm will think my job has finished.(At least I guess)

All informtions that should be printed show up until time.sleep(1) is excuated. Before that, the output log of slurm (similar like the output window when you use the yade sth.py command) is just:

TCP python prompt on localhost:9000, auth cookie `sdkaue'
Welcome to Yade 2018.02b
XMLRPC info provider on http://localhost:21000
Running script gravity.py

Nothing showup but the VTK files are being created, which means the simulations are running.
Any instructions?

[1]https://slurm.schedmd.com/

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
JIPEIQI
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,
just an idea (not tested), would
###
print "whatever"
sys.stdout.flush()
###
help?

Alternatively, you can use a workaround, instead of print, use
sys.stderr.write("whatever\n") # [1]
as this was printed..

Even more workaround, instead of printing, you can open a file and write to it..

cheers
Jan

[1] https://github.com/yade/trunk/blob/master/core/main/main.py.in#L180

Revision history for this message
JIPEIQI (jpq-learning) said :
#2

Hi Jan!
the sys.stderr.write works, thank you so much