This page offers a guide on how to set up AWS for
psiturk to run experiments on prolific.
To use a preconfigured AMI you require access to an account managed by Chris' root AWS management console.
Launch Instance
psiturk-aws
micro
should be enough)400
.chmod 400 /path/to/your/key/your-key.pem
Select existing security group
, search for psiturk-anywhere
and select it.30 GiB gp2
storage.Launch Instance
Clicking on Instances
in the left menu leads you to the overview of all lab-instances running.
Mark your instance, and press the connect
button.
ssh/config
(recommended)your-key.pem
is in the folder ~/.ssh
:# If you do not have a `~/.ssh` folder, create it:
mkdir ~/.ssh
# Copy your-key.pem into the ss folder
cp /path/to/your/key/your-key.pem ~/.ssh
# If you do not have a `~/.ssh/config` create it:
touch ~/.ssh/config
# open with text editor of your choice
vim ~/.ssh/config
.ssh/config
file substituting your-key.pem
and ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com
with your Public DNS.Host aws
HostName ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com
User ubuntu
IdentityFile ~/.ssh/your-key.pem
You can find your public DNS when clicking on the instanceID in the Instances overview.
ssh aws
Log into the AMI.
Important Update system.
sudo apt update && sudo apt -y upgrade
When getting asked Which services should be restarted?
, press <TAB>
and <ENTER>
to continue with pre-selected options.
Reboot AMI
sudo reboot
The connection will be lost and you will need to connect to the AMI again.
On your computer:
rsync -rv your-project-dir aws:~/
On AMI:
# navigate into your project dir
cd <your-repo-dir>
# activate conda
conda activate psiturk
# start psiturk
psiturk server on
# stop psiturk
psiturk server off
Note that the IP address psiturk displays after
psiturk server on
is incorrect. Use thePublic IPv4 address
when clicking on yourInstance ID
in the Instance overview. Append22362
, you should open an address such asXX.X.XXX.XXX:22362
in your browser.
See dbinfo page.
Make the automatic study_id/session_id/prolific_id handling work:
I'll use URL parameters
and paste your URL with the appropriate address:http://XX.X.XXX.XXX:22362/ad?workerId={{%PROLIFIC_PID%}}&assignmentId={{%STUDY_ID%}}&hitId={{%SESSION_ID%}}&mode=live
Replace xx.xxx.xxx.xxx with your AWS Public IPv4 address
PROLIFIC ID: workerId
STUDY ID: assignmentId
SESSION ID: hitId
Set I'll redirect them using a URL
and copy the displayed URL into the appropriate section of templates/thanks_mturksubmit.html
of your psiturk-experiment.
Sync your project to the server. (or edit file on server directly)
Launch Instance
Ubuntu Server 22.04 LTS
, 64-bit
)micro
should be enough)400
.chmod 400 your-key.pem
create security group
, name it.Type
is ssh an d Source type
is set to Anywhere.Add security group rule
: set Type
to Custom TCP Rule, set Port Range
to 22362, set Source type
to Anywhere.30 GiB gp2
storage.Launch Instance
.This section is about installing conda, psiturk, postgresql on Ubuntu Server 22.04 LTS.
Log to the shell.
Important Update system.
sudo apt update && sudo apt -y upgrade
sudo apt install gcc
# make temporary dir, go into
mkdir temp; cd temp
# Download latest version
# Get link for latest version by copying the "Download" link on this site: https://www.anaconda.com/products/distribution#linux
# (green button -> right-click -> copy link)
wget <link>
# Compare your shasum to the appropriate file: https://repo.anaconda.com/archive/. (Just Ctrl+F it)
sha256sum <downloaded-file>
# Install Anaconda
bash <downloaded-file>
# Go through installer steps with default settings.
# When prompted for "Do you wish the installer to initialize Anaconda3 by running conda init?" type yes.
# Source your shell to get access to conda commands
cd; source .bashrc
# Remove temp dir
rm -rd temp
# create conda environment
conda create -n psiturk python=3.9
# activate environment
conda activate psiturk
# install psiturk
pip install psiturk
# for acceleration
pip install python-Levenshtein
# for postgresql
pip install psycopg2-binary
# install old cryptography version to prevent psiturk from breaking
pip install cryptography==38.0.4
Psiturk is now installed.
Follows instructions here: https://www.postgresql.org/download/linux/ubuntu/
Reboot in AWS interface or sudo reboot
.
# open postgresql command interface
sudo -u postgres psql
# change password
\password
CREATE DATABASE <database_name>;
CREATE USER <user> with encrypted password '<password>';
\c <database_name>
GRANT ALL PRIVILEGES ON DATABASE <database_name> TO <user>;
GRANT USAGE, CREATE ON SCHEMA public TO <user>;
\q
Set the config file of postgresql to accept the appropriate requests.
sudo vim /etc/postgresql/15/main/pg_hba.conf
Edit this line:
# "local" is for Unix domain socket connections only
local all all peer
to
# "local" is for Unix domain socket connections only
local all all md5
Psiturk is able to read certain environment variables (see in psiturk config.txt) if following environment variable is set: ON_CLOUD=1
.
For convenience and access security you may do not want to set these variables directly in your repository, but on the server directly.
To achieve that,
.bashrc
on the server:# open bashrc
vim ~/.bashrc
export ON_CLOUD=1
export PORT=22362
export DATABASE_URL=postgres://<user>:<password>@127.0.0.1:5432/<database_name>
source ~/.bashrc
On your computer:
rsync -rv your-project-dir <aws-hostname>:~/
Take care with the '/' operators with this command.
On AMI:
# navigate into your project dir
cd <your-repo-dir>
# activate conda
conda activate psiturk
# start psiturk
psiturk server on
# stop psiturk
psiturk server off
Note that the IP address psiturk displays after
psiturk server on
is incorrect. Use thePublic IPv4 address
when clicking on yourInstance ID
in the Instance overview. Append22362
, you should open an address such asXX.X.XXX.XXX:22362
in your browser.
Psiturk now should run smoothly on your server, with you being able to access via the AWS IP address.