0

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.

Ben Miller
  • 391
  • 3
  • 5

1 Answers1

0

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!

Ben Miller
  • 391
  • 3
  • 5