snapshot engine timeout

Asked by Christian Jakob on 2012-02-07

I to make a video using snapshot engine:

from yade import qt

qt.View()
qt.SnapshotEngine(fileBase='/tmp/snaps/snap-',label='snapper',iterPeriod=100000)

Why do I get a timeout of this engine?

16506 WARN yade.SnapshotEngine gui/qt4/GLViewer.cpp:69 action: Timeout waiting for snapshot to be saved, making byself Engine::dead

I want to read the manual, but it is an empty page:

https://yade-dem.org/doc/yade.qt.html#yade.qt.SnapshotEngine

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Anton Gladky
Solved:
2012-02-15
Last query:
2012-02-15
Last reply:
2012-02-09

You can compile your own version of the manual (see doc/Sphinx/README), and there will be the qt documentation. I hope we will fix that for the online manual to.

Christian Jakob (jakob-ifgt) said : #2

# Sphinx version: 0.6.6
# Docutils version: 0.7 release
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/sphinx/cmdline.py", line 169, in main
    warningiserror, tags)
  File "/usr/lib/pymodules/python2.6/sphinx/application.py", line 94, in __init__
    self.config = Config(confdir, CONFIG_FILENAME, confoverrides, self.tags)
  File "/usr/lib/pymodules/python2.6/sphinx/config.py", line 126, in __init__
    execfile(config['__file__'], config)
  File "/home/me/YADE/yade/doc/sphinx/conf.py", line 27, in <module>
    from sphinx.roles import XRefRole
ImportError: cannot import name XRefRole

What did you type?

Christian Jakob (jakob-ifgt) said : #4

me@debian ~/YADE/yade/doc/sphinx > PYTHONPATH=. yade yadeSphinx.py /home/me/YADE/documentation/

Welcome to Yade bzr2981
TCP python prompt on localhost:9000, auth cookie `ceukds'
XMLRPC info provider on http://localhost:21000
Running script yadeSphinx.py
Running Sphinx v0.6.6

Exception occurred:
  File "/home/me/YADE/yade/doc/sphinx/conf.py", line 27, in <module>
    from sphinx.roles import XRefRole
ImportError: cannot import name XRefRole
The full traceback has been saved in /tmp/sphinx-err-NY7RjF.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-dev/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
Traceback (most recent call last):
  File "/home/me/YADE/YADE2981/bin/yade-bzr2981", line 183, in runScript
    execfile(script,globals())
  File "yadeSphinx.py", line 219, in <module>
    makeBaseClassesClickable((outDir+'/html/yade.wrapper.html' if writer=='html' else outDir+'/latex/Yade.tex'),writer)
  File "yadeSphinx.py", line 151, in makeBaseClassesClickable
    for l in open(f):
IOError: [Errno 2] Datei oder Verzeichnis nicht gefunden: '_build/html/yade.wrapper.html'

I am also wondering, because actually I use bzr3011, not bzr2981 ...
Did i do something wrong? Do I have to compile the whole yade package again with scons?

Anton Gladky (gladky-anton) said : #5

> Running Sphinx v0.6.6

That makes a problem. Python-sphinx version should be >1.0.5

https://launchpad.net/~yade-users/+archive/external/+packages

Anton

For the version question:

This command is actually really running yade and execute special functions from each class, to get documentation:
PYTHONPATH=. yade yadeSphinx.py

I guess you have yade-daily installed (so that yade is in the system's path), so the command is generating the documentation of bzr2981.

For latest version:
PYTHONPATH=. path/to/yade/yade-bzrnnnn yadeSphinx.py

Christian Jakob (jakob-ifgt) said : #7

With the new sphinx version i was able to compile the documentation, thank you anton.

i increased deadTimeout to 100.

qt.SnapshotEngine(fileBase='/tmp/snaps/snap-',label='snapper',iterPeriod=100,deadTimeout=100)

when i run the simulation, i get every 10 seconds a warning, like this one:

12467 WARN yade.SnapshotEngine gui/qt4/GLViewer.cpp:67 action: Already waiting 10s for snapshot to be saved. Something went wrong?

after 100 seconds the engine gets dead and the calculation starts without snapshotengine. so i do not get one snapshot. for running the simulation i use a while command, maybe this is the problem:

while c_clump < 10:
  c_clump = c_clump + 1
  O.run(3000,True)

There must be a stupid detail, like /tmp/snaps/ doesn't exist, or this sort of thing.
I don't think the while command can create problems.
Did you try to set dead=false after a few iterations?

Christian Jakob (jakob-ifgt) said : #9

the folder exists, it has something to do with the while command ... ?!

from yade import qt

v=qt.View()
qt.SnapshotEngine(fileBase='/tmp/snaps/snap-',label='snapper',iterPeriod=1000)
O.run(20000)
raw_input('press ENTER')

# until here it works fine

while c_clump < 10:
  c_clump = c_clump + 1
  O.run(3000,True)

then i get:

58555 WARN yade.SnapshotEngine gui/qt4/GLViewer.cpp:69 action: Timeout waiting for snapshot to be saved, making byself Engine::dead

i will try that dead=false ...

Christian Jakob (jakob-ifgt) said : #10

to reproduce it, try this script:

#!/usr/bin/python
# -*- coding: utf-8 -*-

from yade import qt

#define material properties:
rho = 1000 #density
fric = 2 #friction coefficient
fric_angle = atan(fric) #friction angle in radian
stiff_n = 1e8
stiff_s = 1e8
c_n = 0.0 #normal viscous damping
c_s = 0.0 #shear viscous damping
l_d = 0.7 #local damping

#define a material:
MyMaterial = O.materials.append(ViscElMat(kn=stiff_n, ks=stiff_s, \
cn=c_n, cs=c_s, density=rho, frictionAngle=fric_angle))

#create a sphere:
O.bodies.append(utils.sphere(center=(0,0,1), radius=0.5, material=MyMaterial))

#create a plane facet:
O.bodies.append(geom.facetBox(center=(0,0,0), extents=(1,1,0), fixed=True, material=MyMaterial))

#define engines:
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]), #Axis-aligned bounding box
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Facet_Sphere_ScGeom()], #Interaction geometry
  [Ip2_ViscElMat_ViscElMat_ViscElPhys()], #Interaction physics
  [Law2_ScGeom_ViscElPhys_Basic()], #Contact law
 ),
 GravityEngine(gravity=(0,0,-9.81)),
 NewtonIntegrator(damping=l_d),
 qt.SnapshotEngine(fileBase='/tmp/yade-test-snapshots',label='snapper',iterPeriod=1000),
]

#show geometry:
v=qt.View(); v.axes=True
v.viewDir=Vector3(0,1,-.05)
v.eyePosition=Vector3(0,-5,.5)

O.dt = 1e-6

#this works:--------------------------------------
#O.run(1000000)

#this not:-------------------------------------------
ii=1
while ii < 200:
 ii=ii+1
 O.run(1500,True)

Mmmh... maybe a problem with the "True" in run(N,True).
I remember it tends to freeze the interface, hence maybe also the
display. Sorry, I'm not expert of this feature.

tranviet (tranviet2302) said : #12

Hello,

This also happens to me. To create videos, I have to do this way, for ex:

O.engines = O.engines+[KinemDirectShearCompEngine(compSpeed =0.01,sigma_save=(),temoin_save=(),targetSigma = compress_stress,LOG=False)]

O.run(10000,True)

O.engines = O.engines + [qt.SnapshotEngine(iterPeriod = 500,fileBase='./video-',label='snapshooter')]
O.engines=O.engines + [KinemDirectShearMovingEngine(shearSpeed = 0.01 ,gamma_save=(),temoin_save=(),targetSigma = compress_stress,gammalim=0.03,LOG=False)]

And when the control board appears, press the Start (or Play) button, it will work. Don't type: O.run(XXX,True) in your script ( I don't know why)
Hope it helps you.

Cheers,
Viet

That's it. O.run(...,True) is not refreshing the display, hence the timeout. Type only run(N).
If you need to stop the simulation with a test, you can always use a periodic engine to do so.

Christian Jakob (jakob-ifgt) said : #14

is there a command, where i can disable this synchronised python processing? if i could disable it, then i do not need this ,True within the run command.

I'm not sure I understand your question Christian. You mean stopping the execution of the script until run(N) is completed? This is O.wait() but is exactly the same as O.run(N,True). Same problem with frozen display and timeout.

Christian Jakob (jakob-ifgt) said : #16

No, I mean telling python to process commands step by step (sequentially). When one step is finish, then the next step should be processed. I searched in the internet, but I did not find, what I need ... only something with subprocess ...

Anton Gladky (gladky-anton) said : #17

Christian, if you need to have a video from simulations,
I would strongly recommend you to use vtk-export.

I know, you have problems with Paraview, but I think, you can
try to export video to another format to fix it.

It is much more flexible, than snapshotengine.

Anton

>I mean telling python to process commands step by step (sequentially). When one step is finish, then the next step should be processed.

It is exactly what O.wait() is doing (and so does run(N,True)).

Christian Jakob (jakob-ifgt) said : #19

Bruno, you know, that I came from PFC to Yade. In PFC the scripts are written in programming language FISH. With FISH I use e.g.

def abc
 a=1
end

abc

cycle 1000
print a

In this language the user has not explicitly to say: wait until cycle 1000 is ready and then print a. It is done automatically. In python the user has to say O.wait() after O.run() explicitly. My question is, if it is possible to change the python behavior in general so that I do not have say O.wait(). As I can read out of your comments it seems, that this is not possible.

Anton, I will try that vtk-export. Codecs were updated for debian, so maybe this paraview-bug could be fixed.

Best Anton Gladky (gladky-anton) said : #20

> Anton, I will try that vtk-export. Codecs were updated for debian, so
> maybe this paraview-bug could be fixed.

Try 3.12 version of Paraview, seems, it is stable now.

Anton

Christian Jakob (jakob-ifgt) said : #21

Thanks Anton Gladky, that solved my question.