Hi,
When running "otree test **filename**", I got the <<error message 1>> .
"sqlalchemy.exc.InvalidRequestError: Table 'resource_reproduction_massive_player' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object."
Then, I added the line
__table_args__ = {'extend_existing': True}
to the first lines of three classes below in model.py
class Subsession(BaseSubsession):
class Group(BaseGroup):
class Player(BasePlayer):
and run "otree test **filename**" again.
As a result, I got the <<error message 2">>.
sqlalchemy.exc.ArgumentError: Error creating backref 'resource_reproduction_massive_Subsession' on relationship 'Subsession.session': property of that name exists on mapper 'mapped class Session->otree_session'
I paste full texts of two types of error massages below and attach settings.py, model.py, and test.py.
It's my pleasure if you could give me some pieces of advice.
Kengo SUZUKI
<<error message 1>>
Failed to create session: Table 'resource_reproduction_massive_player' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
Traceback (most recent call last):
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\otree\channels\consumers.py", line 319, in create_session_then_send_start_link
session_pk=
session.id, case_number=None
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\otree\bots\browser.py", line 130, in initialize_session
return browser_bot_worker.initialize_session(**kwargs)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\otree\bots\browser.py", line 54, in initialize_session
num_cases = config.get_num_bot_cases()
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\otree\session.py", line 73, in get_num_bot_cases
bots_module = get_bots_module(app_name)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\otree\common.py", line 69, in get_bots_module
return import_module(f'{app_name}.tests')
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "D:\oTree\Resource_Reproduction_2022-1\resource_reproduction_massive\tests.py", line 2, in
from . import pages
File "D:\oTree\Resource_Reproduction_2022-1\resource_reproduction_massive\pages.py", line 40, in
class Player(BasePlayer):
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\ext\declarative\api.py", line 76, in __init__
_as_declarative(cls, classname, cls.__dict__)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\ext\declarative\base.py", line 131, in _as_declarative
_MapperConfig.setup_mapping(cls, classname, dict_)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\ext\declarative\base.py", line 160, in setup_mapping
cfg_cls(cls_, classname, dict_)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\ext\declarative\base.py", line 190, in __init__
self._setup_table()
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\ext\declarative\base.py", line 538, in _setup_table
**table_kw
File "", line 2, in __new__
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\util\deprecations.py", line 139, in warned
return fn(*args, **kwargs)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\sql\schema.py", line 542, in __new__
"existing Table object." % key
sqlalchemy.exc.InvalidRequestError: Table 'resource_reproduction_massive_player' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
<<error message 2>>
Failed to create session: Error creating backref 'resource_reproduction_massive_Subsession' on relationship 'Subsession.session': property of that name exists on mapper 'mapped class Session->otree_session'
Traceback (most recent call last):
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\otree\channels\consumers.py", line 319, in create_session_then_send_start_link
session_pk=
session.id, case_number=None
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\otree\bots\browser.py", line 130, in initialize_session
return browser_bot_worker.initialize_session(**kwargs)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\otree\bots\browser.py", line 58, in initialize_session
session_pk=session_pk, case_number=case_number, use_browser_bots=True
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\otree\bots\runner.py", line 71, in make_bots
Participant.objects_filter(session_id=session_pk).update(update_kwargs)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\otree\database.py", line 392, in objects_filter
return dbq(cls).filter(*args).filter_by(**kwargs)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\otree\database.py", line 162, in query
return self._db.query(*args, **kwargs)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\orm\session.py", line 1589, in query
return self._query_cls(entities, self, **kwargs)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\orm\query.py", line 197, in __init__
self._set_entities(entities)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\orm\query.py", line 225, in _set_entities
self._set_entity_selectables(self._entities)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\orm\query.py", line 256, in _set_entity_selectables
ent.setup_entity(*d[entity])
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\orm\query.py", line 4324, in setup_entity
self._with_polymorphic = ext_info.with_polymorphic_mappers
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\util\langhelpers.py", line 893, in __get__
obj.__dict__[self.__name__] = result = self.fget(obj)
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\orm\mapper.py", line 2155, in _with_polymorphic_mappers
configure_mappers()
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\orm\mapper.py", line 3299, in configure_mappers
mapper._post_configure_properties()
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\orm\mapper.py", line 1965, in _post_configure_properties
prop.init()
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\orm\interfaces.py", line 197, in init
self.do_init()
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\orm\relationships.py", line 2081, in do_init
self._generate_backref()
File "c:\users\suzukikengo2020\appdata\local\programs\python\python37\lib\site-packages\sqlalchemy\orm\relationships.py", line 2343, in _generate_backref
% (backref_key, self, m)
sqlalchemy.exc.ArgumentError: Error creating backref 'resource_reproduction_massive_Subsession' on relationship 'Subsession.session': property of that name exists on mapper 'mapped class Session->otree_session'