Running experiment from mac. Need help deploying the experiment

85 views
Skip to first unread message

John Mark Johnson

unread,
Jun 26, 2021, 2:05:30 PM6/26/21
to PsiTurk

The experiment is built and I am trying to deploy it from my mac.

I have created a domain name and all of the steps listed
https://psiturk.readthedocs.io/en/latest/tutorials/static-ip-ssl.html

Here is what my config file looks like:
[HIT Configuration]
title=Mental Speed, IQ, & EI
description=A series of cognitive tasks
keywords=
lifetime=1440
us_only=true
approve_requirement=95
number_hits_approved=0
require_master_workers=false
require_quals=
block_quals=
advanced_quals_path=
ad_url_domain= intelligenceexperi2021.com
ad_url_port=443
ad_url_protocol=https
ad_url_route=pub
amt_keywords=Intelligence, Cognition, Cognitive Psychology
approve_requirment=90
contact_email_on_error=johnso...@gmail.com
ad_group=Mental Speed Task
psiturk_keywords=Mental Speed, IQ, Emotional Intelligence
organization_name=Harvard University
browser_exclude_rule=MSIE, mobile, tablet, bot
allow_repeats=false

[Database Parameters]
database_url = mysql://root:xx...@127.0.0.1:3306/xxx
table_name = xxx

[Server Parameters]
host = 0.0.0.0  
port = 80
cutoff_time = 30
logfile = server.log
loglevel = 2
debug = true
login_username = examplename
login_pw = examplepassword
threads = auto

[Task Parameters]
experiment_code_version = 1.0
num_conds = 1
num_counters = 1

[Shell Parameters]
launch_in_sandbox_mode = true
persistent_history_file = .psiturk_history
#bonus_message = "Thanks for participating!"

# If you are not using the psiturk ad server, set `use_psiturk_ad_server` to `false` and point `ad_location` to your proxy server <host> and <port>. Format the ad_location like this:
#
#   https://<host>:<port>/ad

use_psiturk_ad_server = false
ad_location =  https://<host>:<port>/ad

I am not getting the experiment to run anymore as I am assuming it can't locate. Something is wrong with the steps I have done setting url's etc.

Do I need to set my ip address to the 192.0.2.1 like in the example on the site?

I was so close to running this experiment live and now I am facing a new set of challenges with this.

Dave Eargle

unread,
Jun 26, 2021, 2:09:23 PM6/26/21
to John Mark Johnson, PsiTurk
"http://intelligenceexperi2021.com/" domain doesn't exist -- you are not close to running this experiment if you don't actually have a server set up to run this from.

> Do I need to set my ip address to the 192.0.2.1 like in the example on the site?

I'm not sure what this is referring to.

I also noticed that you have the `use_psiturk_ad_server` setting in your config file -- that doesn't exist in a psiturk 3 - generated config file. You might have some other things going on.

--
You received this message because you are subscribed to the Google Groups "PsiTurk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psiturk+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psiturk/ee1b692f-22d3-426b-a363-e61a557d858cn%40googlegroups.com.

Dave Eargle

unread,
Jun 26, 2021, 2:11:44 PM6/26/21
to Dave Eargle, John Mark Johnson, PsiTurk
Oh oh, I see, you're talking about the screenshot. I'm guessing that you actually used "example.com" or something in your config? No absolutely not, do not use 192.0.2.1 if you don't control the server that that IP points to. You need to create a record for  "intelligenceexperi2021.com/" pointing to your server's public ip address.

Dave Eargle

unread,
Jun 26, 2021, 3:06:45 PM6/26/21
to John Mark Johnson, PsiTurk, Dave Eargle
Sorry, I keep messing up the google group thing, forgetting to change my "from" address. Copying the conversation below.

---

I said:

> "http://intelligenceexperi2021.com/" domain doesn't exist -- you are not close to running this experiment if you don't actually have a server set up to run this from.

>> Do I need to set my ip address to the 192.0.2.1 like in the example on the site?

> I'm not sure what this is referring to.

> I also noticed that you have the `use_psiturk_ad_server` setting in your config file -- that doesn't exist in a psiturk 3 - generated config file. You might have some other things going on.

 >Oh oh, I see, you're talking about the screenshot. I'm guessing that you actually used "example.com" or something in your config? No absolutely not, do not use 192.0.2.1 if you don't control the server that that IP points to. You need to create a record for  "intelligenceexperi2021.com/" pointing to your server's public ip address.

Then John said:

> I didn't use example.com. I bought the domain intelligenceexperi2021.com/ to run my experiment from my mac. As I mentioned, I followed the steps given at https://psiturk.readthedocs.io/en/latest/tutorials/static-ip-ssl.html.

> I need to run the experiment from my home computer. I just don't fully understand the steps of doing so. I bought the domain and did all of those things but I am not sure how that domain is connecting to my experiment directory on my mac.

> I could try running the experiment on heroku but when I tried doing all of that yesterday I ran into a whole host of problems as well.

Now my response:

That documentation page is specifically for psiturk users who "have been hosting your own experiments on your own server using a static IP address." Your mac is not a public-facing web server. You can't (easily) serve websites from it. Therefore, you cannot host a psiturk experiment from it.

Also, you may have bought http://intelligenceexperi2021.com/, but visiting the domain reports DNS_PROBE_FINISHED_NXDOMAIN, which means no DNS record exists for it.

But the heroku approach is designed for persons such as yourself who don't have experience with all this networking and server-hosting stuff. You don't say what errors you ran into with the heroku approach, but that's the default approach for typical psiturk users.



On Sat, Jun 26, 2021 at 12:17 PM John Mark Johnson <johnso...@gmail.com> wrote:
I didn't use example.com. I bought the domain intelligenceexperi2021.com/ to run my experiment from my mac. As I mentioned, I followed the steps given at https://psiturk.readthedocs.io/en/latest/tutorials/static-ip-ssl.html.

I need to run the experiment from my home computer. I just don't fully understand the steps of doing so. I bought the domain and did all of those things but I am not sure how that domain is connecting to my experiment directory on my mac.

I could try running the experiment on heroku but when I tried doing all of that yesterday I ran into a whole host of problems as well.

John Mark Johnson

unread,
Jun 26, 2021, 3:10:39 PM6/26/21
to Dave Eargle, PsiTurk, Dave Eargle
Ok so heroku is what I am looking for then.

Here are the heroku errors:

2021-06-26T19:03:33.234645+00:00 heroku[web.1]: State changed from crashed to starting
2021-06-26T19:03:46.374239+00:00 heroku[web.1]: Starting process with command `python herokuapp.py`
2021-06-26T19:03:49.763369+00:00 heroku[web.1]: Process exited with status 2
2021-06-26T19:03:49.933594+00:00 heroku[web.1]: State changed from starting to crashed
2021-06-26T19:03:49.678603+00:00 app[web.1]: python: can't open file '/app/herokuapp.py': [Errno 2] No such file or directory
2021-06-26T19:06:26.608226+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/pub?assignmentId=debug6JZT0A&hitId=debug7GFF6N&workerId=debugBB6JPX&mode=debug" host=thawing-dusk-59473.herokuapp.com request_id=2cf671c3-9bca-4b5c-acef-95d4175a1450 fwd="76.85.97.222" dyno= connect= service= status=503 bytes= protocol=https


John Mark Johnson

unread,
Jun 26, 2021, 3:25:25 PM6/26/21
to Dave Eargle, PsiTurk, Dave Eargle
nevermind, I just got heroku to run the experiment. I am finally ready to run the experiment. I am going to buy a lottery ticket.

Dave Eargle

unread,
Jun 26, 2021, 3:26:56 PM6/26/21
to John Mark Johnson, PsiTurk, Dave Eargle
Glad you got it. For anyone getting the above error -- go through the heroku tutorial again -- https://psiturk.readthedocs.io/en/latest/tutorials/heroku.html#deploy-on-heroku -- step 7 has you run `psiturk-heroku-config`, which among other things, copies `herokuapp.py` into your directory. Make sure it gets committed and pushed to your heroku git repo.

John Mark Johnson

unread,
Jun 26, 2021, 3:29:25 PM6/26/21
to Dave Eargle, PsiTurk, Dave Eargle
Thanks for all your help. I don't know enough about shell scripting to know why this would be an issue but I think what was happening was that I was adding each file one by one (e.g. git add file1 file2 file3) because git add . wouldnt work for me. However, I ran across git add * and then everything worked? I don't know.

John Mark Johnson

unread,
Jun 26, 2021, 4:33:07 PM6/26/21
to Dave Eargle, PsiTurk, Dave Eargle
Last question (god willing), 

So now that I am using postgresql rather than mysql the python data parsing script will no longer work. Do you have any tips for working with the postgresql database? I was hoping I could just plug my database url into the original data parsing script but seem not to be that lucky.

Dave Eargle

unread,
Jun 26, 2021, 5:17:35 PM6/26/21
to John Mark Johnson, PsiTurk, Dave Eargle
>  the python data parsing script will no longer work

Can you provide error messages? Have you installed `psycopg2-binary` (pip install psycopg2-binary) locally?

John Mark Johnson

unread,
Jun 26, 2021, 5:28:52 PM6/26/21
to Dave Eargle, PsiTurk, Dave Eargle
Traceback (most recent call last):
  File "/Users/JMJ/thesis_experiment copy/analysis_new.py", line 40, in <module>
    new_df = df[['uniqueid', 'test_question', 'accuracy', 'task', 'task_condition', 'test_condition', 'question_number']]
  File "/usr/local/lib/python3.9/site-packages/pandas/core/frame.py", line 3030, in __getitem__
    indexer = self.loc._get_listlike_indexer(key, axis=1, raise_missing=True)[1]
  File "/usr/local/lib/python3.9/site-packages/pandas/core/indexing.py", line 1266, in _get_listlike_indexer
    self._validate_read_indexer(keyarr, indexer, axis, raise_missing=raise_missing)
  File "/usr/local/lib/python3.9/site-packages/pandas/core/indexing.py", line 1308, in _validate_read_indexer
    raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Index(['uniqueid', 'test_question', 'accuracy', 'task', 'task_condition', 'test_condition', 'question_number'], dtype='object')] are in the [columns]"

Note this is when i take the database_url that I get from heroku config and plug it into db_url for the data parsing script see here:

from sqlalchemy import create_engine, MetaData, Table
import json
import psycopg2
import pandas as pd
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)

db_url = "postgres://xxxxxxx:c2a497d64a8ccbd04b67a0fe3b4cc6b9...@ec2-107-21-10-179.compute-xxxx:5432/dc88oul40tgjtq"
table_name = 'thesis_exp'
data_column_name = 'datastring'
# boilerplace sqlalchemy setup
engine = create_engine(db_url)
metadata = MetaData()
metadata.bind = engine
table = Table(table_name, metadata, autoload=True)
# make a query and loop through
s = table.select()
rows = s.execute()

data = []
#status codes of subjects who completed experiment
statuses = [3,4,5,7]
# if you have workers you wish to exclude, add them here
exclude = [0]
for row in rows:
    # only use subjects who completed experiment and aren't excluded
    if row['status'] in statuses and row['uniqueid'] not in exclude:
        data.append(row[data_column_name])

data = [json.loads(part)['data'] for part in data]

for part in data:
    for record in part:
        record['trialdata']['uniqueid'] = record['uniqueid']

data = [record['trialdata'] for part in data for record in part]

df = pd.DataFrame(data)

John Mark Johnson

unread,
Jun 26, 2021, 5:29:35 PM6/26/21
to Dave Eargle, PsiTurk, Dave Eargle
this really is the last hurdle and then I think I am there.

John Mark Johnson

unread,
Jun 26, 2021, 6:44:43 PM6/26/21
to Dave Eargle, PsiTurk, Dave Eargle
I am confused why the script I showed above isn't working. If I go to heroku.com and use the dataclip tool, there are 3 debug examples that should show up when I run the script. But for whatever reason nothing is working.

Dave Eargle

unread,
Jun 26, 2021, 7:49:33 PM6/26/21
to John Mark Johnson, PsiTurk, Dave Eargle
Idk, I would do things like log in via `heroku pg:psql` and poke around, then I would look at the datastring column in there to see whether it's empty, then you didn't show your full script but I would attach a debugger and look to see what columns _are_ in the df -- it doesn't say you have 0 rows in there necessarily. Just a game of sleuthing that is hard over email with the fog of reproducibility.

Try the psiturk "download_datafiles" command.

John Mark Johnson

unread,
Jun 26, 2021, 8:19:09 PM6/26/21
to Dave Eargle, Dave Eargle, PsiTurk
Thanks!
Reply all
Reply to author
Forward
0 new messages