[Paraview] Problem with disconnecting from the builtin server in pvpython

Milos Ilak ilak at mech.kth.se
Wed Sep 15 17:35:31 EDT 2010


Hi,

I have a related question. I would like to use the Python interface to
create movies of large datasets from .png files. Having the .pngs gives me
flexibility in encoding them. I know that ParaView can export animations as
.pngs files, but I would like to do this in offscreen mode and without
running the animation in ParaView first.

I haven't been able to figure out how to run a single instance of ParaView
during every iteration of a loop over file names (or, say, camera angles)
within a Python script, i.e. open ParaView, work on one file, output a .png,
and then close ParaView.

The fix below with clearing the pipeline each time seems to work, but I was
wondering if it would be possible to invoke ParaView 'from scratch' during
each call and how. Also, would there be any disadvantages to doing that, as
opposed to having a single instance of ParaView during the entire loop and
clearing the pipeline as below?

I apologize if this has been discussed, but I haven't been able to find any
of those discussions if so.

Milos





On Wed, Sep 15, 2010 at 10:12 PM, logari81 <logari81 at googlemail.com> wrote:

> Thank you for the quick response. You are right, what I actually need is
> to clear the pipeline. Your snippet seems to work well except some
> naming counters which are not reset but in my use case this isn't very
> important.
>
> Thanks a lot for your help.
>
> Best Regards
>
> Kostas
>
> On Wed, 2010-09-15 at 15:49 -0400, pat marion wrote:
> > If your intention is to just clear the pipeline, try this code, copied
> > from the paraview coprocessor template:
> >
> > def GetProxiesToDelete():
> >     iter = servermanager.vtkSMProxyIterator()
> >     iter.Begin()
> >     tobedeleted = []
> >     while not iter.IsAtEnd():
> >       if iter.GetGroup().find("prototypes") != -1:
> >          iter.Next()
> >          continue
> >       proxy = servermanager._getPyProxy(iter.GetProxy())
> >       proxygroup = iter.GetGroup()
> >       iter.Next()
> >       if proxygroup != 'timekeeper' and proxy != None and
> > proxygroup.find("pq_helper_proxies") == -1 :
> >           tobedeleted.append(proxy)
> >
> >     return tobedeleted
> >
> > # explicitly delete the proxies -- we do it this way to avoid problems
> > with prototypes
> > tobedeleted = GetProxiesToDelete()
> > while len(tobedeleted) > 0:
> >    Delete(tobedeleted[0])
> >    tobedeleted = GetProxiesToDelete()
> >
> >
> > On Wed, Sep 15, 2010 at 3:21 PM, pat marion <pat.marion at kitware.com>
> > wrote:
> >         I'm afraid your use case is not well supported.  There is
> >         logic in the paraview gui application that ensures a clean
> >         disconnect, which includes a hard reset of the python
> >         interpreter context.  Using only python modules, there is
> >         manual clean up required after a disconnect that is not yet
> >         supported.
> >
> >         You might find that your script still works, you'll just be be
> >         spammed with those error messages.  Also, try calling
> >         Connect() instead of servermanager.Disconnect(...).  This will
> >         disconnect & reconnect a little more cleanly, but still not
> >         perfect.
> >
> >         Pat
> >
> >
> >
> >
> >         On Wed, Sep 15, 2010 at 2:52 PM, logari81
> >         <logari81 at googlemail.com> wrote:
> >                 In the meanwhile I have realized that the error occurs
> >                 only when I
> >                 include a Delete() statement in my script. Thus the
> >                 following very
> >                 simple script reproduces the error:
> >
> >                 import sys
> >                 sys.path.append('/usr/lib/paraview')
> >                 from paraview.simple import *
> >                 cone = Cone()
> >                 Delete(cone)
> >                 servermanager.Disconnect(servermanager.ActiveConnection)
> >
> >                 Hopefully someone can explain this behavior.
> >
> >                 Best Regards
> >
> >                 Kostas
> >
> >
> >
> >                 On Wed, 2010-09-15 at 18:59 +0200, logari81 wrote:
> >                 > Hi,
> >                 >
> >                 > actually I have the same question as in this
> >                 previous email:
> >                 >
> >                 >
> >
> http://www.paraview.org/pipermail/paraview/2008-March/007506.html
> >                 >
> >                 > I use the python interface in an application that I
> >                 am developing and I
> >                 > import paraview with:
> >                 >
> >                 > from paraview.simple import *
> >                 >
> >                 > During the import a connection to the builtin server
> >                 is also established
> >                 > silently. Though, in my application I need to clear
> >                 the pipeline
> >                 > occasionally in order to begin with a new output, so
> >                 I tried
> >                 > disconnecting from the server with:
> >                 >
> >                 >
> >                 servermanager.Disconnect(servermanager.ActiveConnection)
> >                 >
> >                 > but I receive the error:
> >                 >
> >                 > ERROR:
> >                 >
> >                 In
> /build/buildd/paraview-3.8.0/Servers/Common/vtkProcessModuleConnectionManager.cxx,
> line 175
> >                 > vtkProcessModuleConnectionManager (0x1d33240):
> >                 Invalid connection ID: 5
> >                 >
> >                 > This behavior is tested with ParaView 3.8.0 on
> >                 Ubuntu 10.04.
> >                 >
> >                 > I would be glad for any hints.
> >                 >
> >                 > Kind Regards
> >                 >
> >                 > Kostas
> >                 >
> >
> >
> >                 _______________________________________________
> >                 Powered by www.kitware.com
> >
> >                 Visit other Kitware open-source projects at
> >                 http://www.kitware.com/opensource/opensource.html
> >
> >                 Please keep messages on-topic and check the ParaView
> >                 Wiki at: http://paraview.org/Wiki/ParaView
> >
> >                 Follow this link to subscribe/unsubscribe:
> >                 http://www.paraview.org/mailman/listinfo/paraview
> >
> >
> >
> >
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>



-- 
Miloš Ilak
Linné Flow Centre
KTH Mechanics, Stockholm
+46(0) 8 790-7152
www2.mech.kth.se/~ilak <http://www2.mech.kth.se/%7Eilak/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100915/8f7b769a/attachment-0001.htm>


More information about the ParaView mailing list