I have a python script that contains a number of user defined functions that I have set up a as package locally. I can run all of the functions in the input_processing.py script except for the one that I intend to run in parallel.
Here is the code that imports the package...
import attrition25.input_processing as attrition
I get this error...
NameError: name 'dview' is not defined
This is what the function looks like in input.processing.py...
@dview.parallel(block=True)
def get_dmat_elements(a, b, c):
d = a + b + c
return(d)
I tried sync_imports() and looked at the @interactive decorator, but I couldn't get anywhere. Any help would be appreciated.
Although I don't completely get the scoping, to get the function to work, I had to add this to the beginning of the input_processing.py script...
import ipyparallel as ipp
# Create directView Instance for Parallel Processing
c = ipp.Client()
dview = c[:] # use all engines
I have the same exact block of code in the Jupyter Notebook where I am testing, but that did not work.
Hopefully this helps someone out there.
Cheers!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.