[Paraview] Call Python function with parallel reader without pvbatch directly
Andy Smith
agsmith424 at gmail.com
Tue Jan 26 23:10:34 EST 2016
I'd like to use a driver Python script to call a Python function within a
module that uses ParaView to read a file in parallel and I was wondering
the best way to go about this.
A little background:
The file structure is something like this:
mypythonpackage/
scripts/
my_driver_script.py
mypythonpackage/
paraview/
filewithparaviewstuff.py
utilities.py
The driver script takes inputs and then calls a function in
filewithparaviewstuff.py that uses ParaView to load a large data file and
do some data analysis. I need to load the dataset in parallel since it is
quite large. To get around this in the past I've used two different
methods:
1. Use the subprocess Python package inside the my_driver_script.py to call
the filewithparaviewstuff.py using pvbatch.
2. Use the subprocess Python package inside the my_driver_script.py to
start a pvserver and then connect to this server within the function inside
filewithparaviewstuff.py
The issue I have is the filewithparaviewstuff.py calls some functions in
the utilities.py file. I'm trying to follow PEP 328
<https://www.python.org/dev/peps/pep-0328/> and use import statements
within filewithparaviewstuff.py like:
from .utilities import my_utility_function
inside the filewithparaviewstuff.py but this causes problems
<http://stackoverflow.com/questions/11536764/attempted-relative-import-in-non-package-even-with-init-py>
if I use method 1, of calling the filewithparaviewstuff.py directly with
pvbatch or if I try to make a '__main__' function in the
filewithparaviewstuff.py and call that directly with pvbatch.
Am I doing something fundamentally wrong or has anyone encountered this
situation and come up with a more elegant solution? If not, should I just
keep going with my option 2?
Thanks,
Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20160126/46e6b533/attachment.html>
More information about the ParaView
mailing list