Unhandled exception in thread started by <function wrapper at 0x7f2f82ee3aa0> on Django - django

Unhandled exception occurs while passing function inside models.py in Django (installing by pip install numpy django requests)
I am trying to manipulate face detection api on web using OpenCV, Numpy and Redis.
But i got an exception on passing the fuctions inside the models.py
I am just a newbee on Django framework and Python languages.
Here is my error while running my Django server !
Unhandled exception in thread started by
Traceback (most recent call last):
File "/home/xyz/.xyz/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/home/xyz/.xyz/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run autoreload.raise_last_exception()
File "/home/xyz/.xyz/lib/python2.7/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception
six.reraise(*_exception)
File "/home/xyz/.xyz/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/home/xyz/.xyz/lib/python2.7/site-packages/django/init.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/xyz/.xyz/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/home/xyz/.xyz/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name)
File "/home/xyz/PycharmProjects/xyz_project/OpencvWeb/opencv_api/Face_detection/models.py", line 28, in
class LFace:
File "/home/xyz/PycharmProjects/xyz_project/OpencvWeb/opencv_api/Face_detection/models.py", line 29, in LFace
def init(self, faceRect = LRect(), eyes=[], id = 0, mt = 0, vel = LVector(0,0)):
NameError: name 'LRect' is not defined
And Here is my code in models.py
This is the class for LFace
class LFace:
def __init__(self, faceRect = LRect(), eyes=[], id = 0, mt = 0, vel = LVector(0,0)):
self.face = faceRect.clone()
self.eyes = [e.clone() for e in eyes]
self.id = id
self.name = ''
self.missingTicks = mt
self.velocity = vel
def clone(self):
return LFace(self.face, self.eyes, self.id)
def setAs(self, f2):
self.face = f2.face.clone()
self.eyes = [e.clone() for e in f2.eyes]
self.id = f2.id
self.missintTicks = f2.missingTicks
self.velocity = f2.velocity.clone()
def dist(self, f2, scalar1 = 1.0, scalar2 = 0.2):
#distance is defined as: center differences * scalar1 + size differences * scalar2
d1 = self.face.center().dist(f2.face.center())
d2 = self.face.wh().dist(f2.face.wh())
return d1 * scalar1 + d2 * scalar2
def interpolateTo(self, f2, t):
self.face.interpolateTo(f2.face, t)
self.eyes = f2.clone().eyes if t > 0.5 else []
def getPredicted(self):
rv = self.clone()
p = rv.face.center()
oldP = p.clone()
p += self.velocity
rv.velocity = LVector(0,0)
rv.face.setFromCenter(p)
return rv
This is the class for LRect
class LRect:
def __init__(self, x=0, y=0, w=0, h=0):
self.x = x
self.y = y
self.w = w
self.h = h
def pos(self):
return LVector(self.x, self.y)
def wh(self):
return LVector(self.w, self.h)
def hwh(self):
return LVector(self.w, self.h) * 0.5
def center(self):
return (self.pos() + self.hwh())
def toString(self):
return '[x={0},y={1},width={2},height={3}]'.format(*self.toList())
def __str__(self):
return self.toString()
def toList(self):
return [self.x, self.y, self.w, self.h]
def clone(self):
return LRect(self.x, self.y, self.w, self.h)
def setFromCenter(self, centerPoint):
hp = self.hwh()
self.x = centerPoint[0] - hp[0]
self.y = centerPoint[1] - hp[1]
def scaleWH(self, scalar):
# scalar can be either an LVector or a number
c = self.center()
hwh = self.wh() * scalar
self.w, self.h = hwh[0], hwh[1]
self.setFromCenter(c)
def interpolateTo(self, r2, t):
c = self.center()
wh = self.wh()
c.interpolateTo(r2.center(), t)
wh.interpolateTo(r2.wh(), t)
self.w, self.h = wh[0], wh[1]
self.setFromCenter(c)
Please Help !!

Related

Python Zipline : "pandas_datareader._utils.RemoteDataError" & local data

It's my first post, I hope it will be well done.
I'm trying to run the following ZipLine Algo with local AAPL data :
import pandas as pd
from collections import OrderedDict
import pytz
from zipline.api import order, symbol, record, order_target
from zipline.algorithm import TradingAlgorithm
data = OrderedDict()
data['AAPL'] = pd.read_csv('AAPL.csv', index_col=0, parse_dates=['Date'])
panel = pd.Panel(data)
panel.minor_axis = ['Open', 'High', 'Low', 'Close', 'Volume', 'Price']
panel.major_axis = panel.major_axis.tz_localize(pytz.utc)
print panel["AAPL"]
def initialize(context):
context.security = symbol('AAPL')
def handle_data(context, data):
MA1 = data[context.security].mavg(50)
MA2 = data[context.security].mavg(100)
date = str(data[context.security].datetime)[:10]
current_price = data[context.security].price
current_positions = context.portfolio.positions[symbol('AAPL')].amount
cash = context.portfolio.cash
value = context.portfolio.portfolio_value
current_pnl = context.portfolio.pnl
# code (this will come under handle_data function only)
if (MA1 > MA2) and current_positions == 0:
number_of_shares = int(cash / current_price)
order(context.security, number_of_shares)
record(date=date, MA1=MA1, MA2=MA2, Price=
current_price, status="buy", shares=number_of_shares, PnL=current_pnl, cash=cash, value=value)
elif (MA1 < MA2) and current_positions != 0:
order_target(context.security, 0)
record(date=date, MA1=MA1, MA2=MA2, Price=current_price, status="sell", shares="--", PnL=current_pnl, cash=cash,
value=value)
else:
record(date=date, MA1=MA1, MA2=MA2, Price=current_price, status="--", shares="--", PnL=current_pnl, cash=cash,
value=value)
#initializing trading enviroment
algo_obj = TradingAlgorithm(initialize=initialize, handle_data=handle_data)
#run algo
perf_manual = algo_obj.run(panel)
#code
#calculation
print "total pnl : " + str(float(perf_manual[["PnL"]].iloc[-1]))
buy_trade = perf_manual[["status"]].loc[perf_manual["status"] == "buy"].count()
sell_trade = perf_manual[["status"]].loc[perf_manual["status"] == "sell"].count()
total_trade = buy_trade + sell_trade
print "buy trade : " + str(int(buy_trade)) + " sell trade : " + str(int(sell_trade)) + " total trade : " + str(int(total_trade))
I was inspired by https://www.quantinsti.com/blog/introduction-zipline-python/ and https://www.quantinsti.com/blog/importing-csv-data-zipline-backtesting/.
I get this error :
Traceback (most recent call last):
File "C:/Users/main/Desktop/docs/ALGO_TRADING/_DATAS/_zipline_data_bundle /temp.py", line 51, in <module>
algo_obj = TradingAlgorithm(initialize=initialize, handle_data=handle_data)
File "C:\Python27-32\lib\site-packages\zipline\algorithm.py", line 273, in __init__
self.trading_environment = TradingEnvironment()
File "C:\Python27-32\lib\site-packages\zipline\finance\trading.py", line 99, in __init__
self.bm_symbol,
File "C:\Python27-32\lib\site-packages\zipline\data\loader.py", line 166, in load_market_data
environ,
File "C:\Python27-32\lib\site-packages\zipline\data\loader.py", line 230, in ensure_benchmark_data
last_date,
File "C:\Python27-32\lib\site-packages\zipline\data\benchmarks.py", line 50, in get_benchmark_returns
last_date
File "C:\Python27-32\lib\site-packages\pandas_datareader\data.py", line 137, in DataReader
session=session).read()
File "C:\Python27-32\lib\site-packages\pandas_datareader\base.py", line 181, in read
params=self._get_params(self.symbols))
File "C:\Python27-32\lib\site-packages\pandas_datareader\base.py", line 79, in _read_one_data
out = self._read_url_as_StringIO(url, params=params)
File "C:\Python27-32\lib\site-packages\pandas_datareader\base.py", line 90, in _read_url_as_StringIO
response = self._get_response(url, params=params)
File "C:\Python27-32\lib\site-packages\pandas_datareader\base.py", line 139, in _get_response
raise RemoteDataError('Unable to read URL: {0}'.format(url))
pandas_datareader._utils.RemoteDataError: Unable to read URL: http://www.google.com/finance/historical?q=SPY&startdate=Dec+29%2C+1989&enddate=Dec+20%2C+2017&output=csv
I don't understand : "http://www.google.com/finance/historical?q=SPY&startdate=Dec+29%2C+1989&enddate=Dec+20%2C+2017&output=csv".
I don't ask for online data request... and not 'SPY' stock but 'APPL'...
What does this error mean to you ?
Thanks a lot for your help !
C.
Only reference and workaround I found regarding this issue is here:
from pandas_datareader.google.daily import GoogleDailyReader
#property
def url(self):
return 'http://finance.google.com/finance/historical'
GoogleDailyReader.url = url
do:
pip install fix_yahoo_finance
then modify the file: zipline/lib/pythonx.x/site-packages/zipline/data/benchmarks.py
add the following two statements to the file:
import fix_yahoo_finance as yf
yf.pdr_override ()
then change following instruction:
data = pd_reader.DataReader (symbol, 'Google' first_date, last_date)
to:
data = pd_reader.get_data_yahoo(symbol,first_date, last_date)

How to access static variable inside static method in python

I've the following class in Python. This class is a utility class for a game of chess I'm building. It consists majority of static variables and I'm running into trouble when I try to access the static variable in a static method.
class BoardUtils:
NUM_TILES = 64
NUM_TILES_PER_ROW = 8
#staticmethod
def init_column(column):
grid = [False] * BoardUtils.NUM_TILES
for i in range(0 + column, BoardUtils.NUM_TILES, BoardUtils.NUM_TILES_PER_ROW):
grid[i] = True
return grid
#staticmethod
def init_row(row):
grid = [False] * BoardUtils.NUM_TILES
for i in range(BoardUtils.NUM_TILES_PER_ROW * row,
BoardUtils.NUM_TILES_PER_ROW * (row + 1)):
grid[i] = True
return grid
FIRST_COLUMN = init_column.__func__(0)
SECOND_COLUMN = init_column.__func__(1)
SEVENTH_COLUMN = init_column.__func__(6)
EIGHTH_COLUMN = init_column.__func__(7)
SECOND_ROW = init_row.__func__(1)
SEVENTH_ROW = init_row.__func__(6)
while compiling, it gives me following error.
Traceback (most recent call last):
File "alice5500.py", line 27, in <module>
class BoardUtils:
File "alice5500.py", line 46, in BoardUtils
FIRST_COLUMN = init_column.__func__(0)
File "alice5500.py", line 33, in init_column
grid = [False] * BoardUtils.NUM_TILES
NameError: global name 'BoardUtils' is not defined
What can be a workaround in this?

type matching error in theano [ Cannot convert Type Generic (of Variable <Generic>) into Type TensorType]

thisfile.py
import cPickle
import gzip
import os
import numpy
import theano
import theano.tensor as T
def load_data(dataset):
f = gzip.open(dataset, 'rb')
train_set, valid_set, test_set = cPickle.load(f)
f.close()
def shared_dataset(data_xy, borrow=True):
data_x, data_y = data_xy
shared_x = theano.shared(numpy.asarray(data_x,
dtype=theano.config.floatX),
borrow=borrow)
shared_y = theano.shared(numpy.asarray(data_y,
dtype=theano.config.floatX),
borrow=borrow)
return shared_x, T.cast(shared_y, 'int32')
test_set_x, test_set_y = shared_dataset(test_set)
valid_set_x, valid_set_y = shared_dataset(valid_set)
train_set_x, train_set_y = shared_dataset(train_set)
rval = [(train_set_x, train_set_y), (valid_set_x, valid_set_y),
(test_set_x, test_set_y)]
return rval
class PCA(object):
def __init__(self):
self.param = 0
def dimemsion_transform(self, X):
m_mean = T.mean(X, axis=0)
X = X - m_mean ##################### this line makes error
return X
if __name__ == '__main__':
dataset = 'mnist.pkl.gz'
# load the MNIST data
data = load_data(dataset)
X = T.matrix('X')
m_pca = PCA()
transform = theano.function(
inputs=[],
outputs=m_pca.dimemsion_transform(X),
givens={
X: data
}
)
error showing like below
Traceback (most recent call last):
File ".../thisfile.py", line 101, in <module>
X: data
File ".../Theano/theano/compile/function.py", line 322, in function
output_keys=output_keys)
File ".../Theano/theano/compile/pfunc.py", line 443, in pfunc
no_default_updates=no_default_updates)
File ".../Theano/theano/compile/pfunc.py", line 219, in rebuild_collect_shared
cloned_v = clone_v_get_shared_updates(v, copy_inputs_over)
File ".../Theano/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates
clone_v_get_shared_updates(i, copy_inputs_over)
File ".../Theano/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates
clone_v_get_shared_updates(i, copy_inputs_over)
File ".../Theano/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates
clone_v_get_shared_updates(i, copy_inputs_over)
File ".../Theano/theano/compile/pfunc.py", line 96, in clone_v_get_shared_updates
[clone_d[i] for i in owner.inputs], strict=rebuild_strict)
File ".../Theano/theano/gof/graph.py", line 242, in clone_with_new_inputs
new_inputs[i] = curr.type.filter_variable(new)
File ".../Theano/theano/tensor/type.py", line 234, in filter_variable
self=self))
TypeError: Cannot convert Type Generic (of Variable <Generic>) into Type TensorType(float64, matrix). You can try to manually convert <Generic> into a TensorType(float64, matrix).
I am making PCA function with theano but have a problem.
mean value is subtracted from MNIST data in dimension_transform in PCA class
I do not get why it gives type matching error and how do I fix it
Your problem comes from these lines:
data = load_data(dataset)
Here data is a list (as this is what load_data() returns).
transform = theano.function(
inputs=[],
outputs=m_pca.dimemsion_transform(X),
givens={
X: data
}
)
And here you pass it as a value. You have to extract the item you want from the return value of load_data() like so:
[(train_set_x, train_set_y), (valid_set_x, valid_set_y),
(test_set_x, test_set_y)] = load_data(dataset)
and then use
givens={
X: train_set_x
}
or one of the other values.

AttributeError: 'QSlider' object has no attribute 'subtractStep'

I am getting an error when I try to run this code:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'scaler_gui_3.ui'
#
# Created: Thu May 14 13:05:28 2015
# by: PyQt4 UI code generator 4.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(270, 219)
self.gridLayout_2 = QtGui.QGridLayout(Form)
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
self.horizontalSliderFrames = QtGui.QSlider(Form)
self.horizontalSliderFrames.setOrientation(QtCore.Qt.Horizontal)
self.horizontalSliderFrames.setObjectName(_fromUtf8("horizontalSliderFrames"))
self.gridLayout_2.addWidget(self.horizontalSliderFrames, 1, 0, 1, 1)
self.gridLayout = QtGui.QGridLayout()
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.verticalScrollBarIW = QtGui.QScrollBar(Form)
self.verticalScrollBarIW.setOrientation(QtCore.Qt.Vertical)
self.verticalScrollBarIW.setObjectName(_fromUtf8("verticalScrollBarIW"))
self.gridLayout.addWidget(self.verticalScrollBarIW, 0, 2, 1, 1)
self.verticalLayout_2 = QtGui.QVBoxLayout()
self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
self.labelMain = QtGui.QLabel(Form)
self.labelMain.setObjectName(_fromUtf8("labelMain"))
self.verticalLayout_2.addWidget(self.labelMain)
self.horizontalScrollBarIW = QtGui.QScrollBar(Form)
self.horizontalScrollBarIW.setOrientation(QtCore.Qt.Horizontal)
self.horizontalScrollBarIW.setObjectName(_fromUtf8("horizontalScrollBarIW"))
self.verticalLayout_2.addWidget(self.horizontalScrollBarIW)
self.gridLayout.addLayout(self.verticalLayout_2, 0, 0, 1, 1)
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem, 0, 1, 1, 1)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
self.horizontalLayout_2 = QtGui.QHBoxLayout()
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
self.gridLayout_2.addLayout(self.horizontalLayout_2, 6, 1, 1, 1)
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.horizontalLayout_3 = QtGui.QHBoxLayout()
self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
self.labelSmallIW = QtGui.QLabel(Form)
self.labelSmallIW.setObjectName(_fromUtf8("labelSmallIW"))
self.horizontalLayout_3.addWidget(self.labelSmallIW)
self.labelBigIW = QtGui.QLabel(Form)
self.labelBigIW.setObjectName(_fromUtf8("labelBigIW"))
self.horizontalLayout_3.addWidget(self.labelBigIW)
self.pushButton = QtGui.QPushButton(Form)
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.horizontalLayout_3.addWidget(self.pushButton)
self.verticalLayout.addLayout(self.horizontalLayout_3)
self.gridLayout_2.addLayout(self.verticalLayout, 4, 0, 1, 1)
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.toolButtonLoad = QtGui.QToolButton(Form)
self.toolButtonLoad.setObjectName(_fromUtf8("toolButtonLoad"))
self.horizontalLayout.addWidget(self.toolButtonLoad)
self.prevButton = QtGui.QPushButton(Form)
self.prevButton.setObjectName(_fromUtf8("prevButton"))
self.horizontalLayout.addWidget(self.prevButton)
self.nextButton = QtGui.QPushButton(Form)
self.nextButton.setObjectName(_fromUtf8("nextButton"))
self.horizontalLayout.addWidget(self.nextButton)
self.gridLayout_2.addLayout(self.horizontalLayout, 2, 0, 1, 1)
self.checkBox = QtGui.QCheckBox(Form)
self.checkBox.setObjectName(_fromUtf8("checkBox"))
self.gridLayout_2.addWidget(self.checkBox, 5, 0, 1, 1)
self.retranslateUi(Form)
QtCore.QObject.connect(self.prevButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.horizontalSliderFrames.subtractStep)
QtCore.QObject.connect(self.nextButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.horizontalSliderFrames.addStep)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form", None))
self.labelMain.setText(_translate("Form", "TextLabel", None))
self.labelSmallIW.setText(_translate("Form", "TextLabel", None))
self.labelBigIW.setText(_translate("Form", "TextLabel", None))
self.pushButton.setText(_translate("Form", "PushButton", None))
self.toolButtonLoad.setText(_translate("Form", "...", None))
self.prevButton.setText(_translate("Form", "<", None))
self.nextButton.setText(_translate("Form", ">", None))
self.checkBox.setText(_translate("Form", "CheckBox", None))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
app.setStyle('cleanlooks')
Form = QtGui.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
It seems like similar error happen to other people due to some "class related problems" which I have no idea about. I do not understand why it seems to work fine when I "run" in from Geany text editor, but not when I run it from terminal using python my_gui.py I get this error :
Traceback (most recent call last):
File "gui_template.ui.py", line 136, in <module>
ui = Ui_Form()
File "gui_template.ui.py", line 39, in __init__
self.setupUi(self)
File "gui_template.ui.py", line 89, in setupUi
QtCore.QObject.connect(self.prevButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.horizontalSliderFrames.subtractStep)
AttributeError: 'QSlider' object has no attribute 'subtractStep'
I also tried creating a seperate .py file in a similar fashion to how this person does it:
https://youtu.be/FcX2FsPlVeI?t=10m25s
However, I still get the same error... Any ideas?
The addStep and subtractStep slots are deprecated members of QSlider. They are only there to provide backwards compatibility with Qt3.
It seems you must be trying to run the example script using builds of Qt4/PyQt4 that do not include such deprecated APIs.
The documentation suggests using the setValue slot instead. But that requires passing an appropriate increment/decrement value, so it's not really a drop-in replacement (especially if you're connecting the signals via Qt Designer).
If you wanted to fix the example, you'd have to replace the two signal/slot connections with something like:
def setSlider(delta):
self.horizontalSliderFrames.setValue(
self.horizontalSliderFrames.value() +
delta * self.horizontalSliderFrames.singleStep())
self.prevButton.clicked.connect(lambda: setSlider(-1))
self.nextButton.clicked.connect(lambda: setSlider(+1))

Django- Factory boy failing for no apparent reason in just one factory

The code:
class StockFactory(UniqueObjectsFactory):
FACTORY_FOR = Stock
FACTORY_DJANGO_GET_OR_CREATE = ('name', 'market')
market = factory.SubFactory(MarketFactory)
symbol = FuzzyAttribute(lambda: ''.join(random.choice(string.ascii_uppercase) for _ in xrange(4)))
name = FuzzyCompanyName()
# last_trade_price = fuzzy.FuzzyDecimal(0.0, 10000.0)
class PositionsFactory(FreezeableFactory):
FACTORY_FOR = Position
FACTORY_DJANGO_GET_OR_CREATE = ('stock','AnotherObject')
id = FuzzyInteger(100000)
stock = factory.SubFactory(Stock)
AnotherObject = factory.SubFactory(AnotherObject) #If I comment stock out it would fail here
created_date = FuzzyDateTime(start_dt=datetime(2013, 1, 1, tzinfo=compat.UTC))
The error:
File "/home/alon/Projects/stox-server/execution/tests/functional/test_positions.py", line 21, in setUp
PositionsFactory.create( portfolio=self.portfolio)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/base.py", line 522, in create
attrs = cls.attributes(create=True, extra=kwargs)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/base.py", line 365, in attributes
force_sequence=force_sequence,
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/containers.py", line 283, in build
return stub.__fill__()
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/containers.py", line 83, in __fill__
res[attr] = getattr(self, attr)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/containers.py", line 105, in __getattr__
val = val.evaluate(self, self.__containers)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/containers.py", line 215, in evaluate
containers=containers,
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/declarations.py", line 75, in evaluate
return self.function(obj)
File "/home/alon/Projects/stox-server/execution/tests/common/factories.py", line 173, in <lambda>
symbol = factory.LazyAttribute(lambda pos: pos.stock.symbol)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/containers.py", line 105, in __getattr__
val = val.evaluate(self, self.__containers)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/containers.py", line 215, in evaluate
containers=containers,
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/declarations.py", line 299, in evaluate
return self.generate(sequence, obj, create, defaults)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/declarations.py", line 386, in generate
return subfactory.simple_generate(create, **params)
AttributeError: type object 'Stock' has no attribute 'simple_generate'
Any clues? Ideas? I work with factory-boy quite a lot and most of the time it's an excellent tool. but after hours of debugging I just cant find the problem
So stupid of me:
Those line are wrong:
stock = factory.SubFactory(Stock)
AnotherObject = factory.SubFactory(AnotherObject)
Should have been:
stock = factory.SubFactory(StockFactory)
AnotherObject = factory.SubFactory(AnotherObjectFactory)
Hope it helps anyone else who bumps into this issue