Hi Chris,
Thank you very much for your
help. If you say I can ignore the warning than it is OK for me. I just
hope it is not a problem when running a session with 60 participants.
I get the warning with the following code in app 1:
# FUNCTIONS
def creating_session(subsession: Subsession):
import random
if subsession.round_number == 1:
subsession.group_randomly(fixed_id_in_group=True)
matrix = subsession.get_group_matrix()
subsession.set_group_matrix(matrix)
subsession.session.vars['id_matrix'] = matrix
print(matrix)
print(subsession.session.vars['id_matrix'])
print(subsession.get_group_matrix())
else:
subsession.set_group_matrix(subsession.session.vars['id_matrix'])#subsession.group_like_round(1)#subsession.set_group_matrix(subsession.session.vars['id_matrix'])
print(subsession.session.vars['id_matrix'])
print(subsession.get_group_matrix())
and the following code in app 2:
# FUNCTIONS
def creating_session(subsession: Subsession):
import random
if "id_matrix" in subsession.session.vars:
subsession.set_group_matrix(subsession.session.vars['id_matrix'])
else:
subsession.group_randomly()
print("new app data")
print(subsession.get_group_matrix())
print(subsession.session.vars['id_matrix'])
The
grouping works fine but the warning appears as you can see on the
following output of the terminal of the test run with 4 participants:
[[3, 2], [1, 4]]
[[3, 2], [1, 4]]
[[3, 2], [1, 4]]
[[3, 2], [1, 4]]
[[3, 2], [1, 4]]
c:\users\...\pycharmprojects\otree_development\venv\lib\site-packages\sqlalchemy\orm\session.py:1956:
SAWarning: Identity map already had an identity for (<class
'redistribute.Group'>, (112,), None), replacing it with newly
flushed object. Are there load operations occurring inside of an event handler within the flush?
"within the flush?" % (instance_key,)
c:\users\...\pycharmprojects\otree_development\venv\lib\site-packages\sqlalchemy\orm\session.py:1956:
SAWarning: Identity map already had an identity for (<class
'redistribute.Group'>, (113,), None), replacing it with newly
flushed object. Are there load operations occurring inside of an event handler within the flush?
"within the flush?" % (instance_key,)
new app data
[[3, 2], [1, 4]]
[[3, 2], [1, 4]]
and the sessions data:
participant id group.id_in_session
P1 2
P2 1
P3 1
P4 2
Thank you and best,
AK