StanFit4Model TypeError: __init__() takes exactly 2 positional arguments (1 given)

stanc

#1

Here is something so embedded in stan, I can’t begin to debug. I have ep-stan code running just fine, but when I attempt to parallelize it by dishing out worker code to worker nodes, I get a strange error

File “/usr/local/lib64/python2.7/site-packages/pystan/model.py”, line 666, in sampling
fit = self.fit_class(data)
File “stanfit4SimpleAdAttribEP_sg_f3b10500566451c7863bb6c6a0d1260c_7800964287842110052.pyx”, line 463, in stanfit4SimpleAdAttribEP_sg_f3b10500566451c7863bb6c6a0d1260c_7800964287842110052.StanFit4Model.init
TypeError: init() takes exactly 2 positional arguments (1 given)

This .pyx file seems to be a temporary file, so I can’t open it to exam, and I don’t know at which stage it get generated, therefore, no clue why there is this signature mismatch.

Can any stan interior expert shed some light?


#2

How are you parallelizing it? Is the fit being pickled on some master
node and then unpickled on a worker node?

Can you share a bit more of the code?


#3

The code would be a handful. let’s please talk this thru. The parallelization is pyspark. as far as pickling, the unpickling is done in the master only and passed to the workers.

sm = cPickle.load(zf.open(filename+'.pkl'))

This code and env is first tested in serial mode and works completely before parallelization. Of course a serrialization of the model object has to take place during the passing, but spark takes care of that. What do you think?


#4

its complaining about

what is the signature of init()? it is not in the documentation for StanFitModel.


#5

I found this in the stanfitmodel.pyc template file

def __init__(self, data):
    self.data = data

sure looks like the method only takes one argument. So, why do I get this error?


#6

The underscores are significant and different between the title and the traceback you cite. Your error smells like an unbound method call, maybe double check use of pyspark.

edit nevermind I see markdown bold init which means it is double underscored. Definitely an unbound method call.


#7

Hi, I am not sure what is the problem, but I could bet that this might be somehow related to Threading, which does not work with PyStan.

That is the best we can say without any code.

Also, did you run with verbose=True?


#8

magically disappeared.