Skip to content

Commit

Permalink
Merge 7f4d228 into d31eb74
Browse files Browse the repository at this point in the history
  • Loading branch information
gureckis committed Apr 27, 2021
2 parents d31eb74 + 7f4d228 commit 6941355
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Add custom MTurk qualification support (#493)
- Added configuration option for changing autogenerated dashboard-related tables to be unique per experiment

## [3.1.0]
### Added
Expand Down
11 changes: 9 additions & 2 deletions doc/databases_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ See :ref:`deploy-on-heroku`.
Using a SQL database server
~~~~~~~~~~~~~~~~~~~~~~~~~~~

A more robust solution is to set up a `MySQL <http://www.mysql.com/>`__ database.
Similar to postgresql on Heroku, another robust solution is to set up a `MySQL <http://www.mysql.com/>`__ database.
psiTurk's reliance on `SQLAlchemy`_ for interfacing
with database which means it is easy to switch between MySQL, PostgreSQL, or SQLite.

Expand Down Expand Up @@ -125,7 +125,14 @@ The table specified in config.txt::

table_name = turkdemo

...will be created automatically when running the psiturk shell.
...will be created automatically when running the psiturk shell. In addition two other tables are
automatically created (`amt_hit` and `campaign` which are used to schedule repeating tasks
and hits). If `table_prefix` is set to `true` in the config files these table names are
made to match the main data table (e.g., `amt_hit` becomes `turkdemo_amt_hit` and `campaign`
becomes `turkdemo_campaign`). This is useful if the database is used my multiple people.

table_prefix = true

MySQL is (fairly) easy to install and free. However, a variety of web hosting
services offer managed MySQL databases. Some are even
`free <https://www.google.com/search?q=free+mysql+hosting>`__.
Expand Down
14 changes: 14 additions & 0 deletions doc/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,22 @@ design where it not longer matters that someone has done a
previous version of the task, you can change the `table_name`
value and begin sorting the data into a new table.

table_prefix
~~~~~~~~~~

Specifies if the extra tables created by psiturk should have
the value of `table_name` set as as a prefix.

:Type: ``bool``
:Default: ``false``

The psiTurk dashboard creates to additional tables called `amt_hit`
and `campaign` to manage aspects of the dashboard interface.
If the database is shared across users or psiturk tasks then these
tables can conflict. Setting `table_prefix` to `true` will prefix
these values with the unique table name profied in `table_name`.
For instance is `table_name` is `exp1` then `amt_hit` becomes
`exp1_amt_hit` and `campaign` becomes `exp1_campaign`.

Server Parameters
-----------------
Expand Down
6 changes: 6 additions & 0 deletions psiturk/default_configs/local_config_defaults.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ database_url = sqlite:///participants.db
# Name of the database table where participant data will be stored
table_name = assignments

# psiturk creates two additional tables named `amt_hit` and `campaign` for
# managing other aspects. if you use one database with multiple psiturk
# users/experiments then set this value to true so that these tables
# will be prefixed with `table_name` set above
table_prefix = false

############################# Server Parameters ################################
[Server Parameters]
# Host on which the psiturk gunicorn server will listen when `psiturk server on`
Expand Down
6 changes: 6 additions & 0 deletions psiturk/example/config.txt.sample
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
# Name of the database table where participant data will be stored
;table_name = assignments

# psiturk creates two additional tables named `amt_hit` and `campaign` for
# managing other aspects. if you use one database with multiple psiturk
# users/experiments then set this value to true so that these tables
# will be prefixed with `table_name` set above
table_prefix = true

############################# Server Parameters ################################
[Server Parameters]
# Host on which the psiturk gunicorn server will listen when `psiturk server on`
Expand Down
13 changes: 11 additions & 2 deletions psiturk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@


TABLENAME = config.get('Database Parameters', 'table_name')
TABLE_PREFIX = config.getboolean('Database Parameters', 'table_prefix')
CODE_VERSION = config.get('Task Parameters', 'experiment_code_version')

if TABLE_PREFIX:
AMT_HIT_TABLENAME = TABLENAME+'_amt_hit'
CAMPAIGN_TABLENAME = TABLENAME+'_campaign'
else:
AMT_HIT_TABLENAME = 'amt_hit'
CAMPAIGN_TABLENAME = 'campaign'

# Base class

Base = declarative_base()
Expand Down Expand Up @@ -205,14 +213,15 @@ def all_but_datastring(cls):
class Hit(Base):
"""
"""
__tablename__ = 'amt_hit'
__tablename__ = AMT_HIT_TABLENAME
hitid = Column(String(128), primary_key=True)


class Campaign(Base):
"""
"""
__tablename__ = 'campaign'

__tablename__ = CAMPAIGN_TABLENAME
id = Column(Integer, primary_key=True)
codeversion = Column(String(128), nullable=False)
mode = Column(String(128), nullable=False)
Expand Down

0 comments on commit 6941355

Please sign in to comment.