fredcallaway / heroku-experiment

Starter kit for running a psiturk experiment on heroku with jspsych.
http://salty-meadow-30207.herokuapp.com/
MIT License
7 stars 9 forks source link

Data Not Saving in Local participant.db File on PsiTurk 3.3.1 with Heroku #566 #19

Open RhtK07 opened 2 months ago

RhtK07 commented 2 months ago

Context PsiTurk Version: 3.3.1 Hosting Platform: Heroku Experiment Repository: fredcallaway/heroku-experiment Problem Description

The experiment runs perfectly fine, and participants can complete and submit the experiment. However, the data is not being saved in the local participant.db file. Consequently, when attempting to approve workers, I receive the following error:

Response(Operation: approve_assignment_by_assignment_id | Status: error | Exception: AssignmentIdNotFoundInLocalDBError: )

Steps to Reproduce

  1. Deploy the experiment to Heroku following the steps provided in the repository fredcallaway/heroku-experiment. changes the config file with the ad url
  2. Run the experiment to completion.
  3. Submit the experiment.
  4. Check the local participant.db file for saved data.
  5. Attempt to approve a worker using the worker approve command.

Observed Behavior

  1. Experiment runs and completes without issues.
  2. Data submission appears to be successful on the frontend.
  3. No data is saved in the participant.db file.
  4. Attempting to approve workers results in AssignmentIdNotFoundInLocalDBError.

Expected Behavior

  1. Data should be saved in the participant.db file upon experiment completion and submission.
  2. Worker approval should proceed without errors.
  3. Any help or suggestions on resolving this issue would be greatly appreciated. Thank you!

fredcallaway commented 2 months ago

participants.db is only used for local testing. Data will be saved there if you run the experiment locally (I think make dev?)

The data generated online should be saved in the heroku psql server. You can get the db location with heroku config:get DATABASE_URL. You can also view it with heorku psql.

But if you just want to download the data, you should be able to just run bin/fetch_data.py

As for using the psiturk command line to approve people (if that's what you're doing), that won't work directly because the database location is not set in config.txt (for security reasons). @cgc might have advice here.

I've been running on Prolific exclusively, so I don't really remember how I was approving/bonusing MTurk participants. I think I used this script at one point—maybe it will be of help. https://github.com/fredcallaway/webofcash/blob/retention/bin/compensation.py

If you are using Prolific, then you can try bin/prolific.py pay (there are other useful commands, see the CLI methods)

RhtK07 commented 2 months ago

Hi there,

Thank you for getting back to me. I have a couple of follow-up questions:

  1. Broken Link: The link you provided (https://github.com/fredcallaway/webofcash/blob/retention/bin/compensation.py) does not seem to be working. Could you please check the link or provide the correct one?
  2. Specifying Database Path in Config File: To ensure the data is saved correctly to the Heroku PostgreSQL database, I would like to confirm if specifying the database URL in the config.txt file as follows is the correct approach: [Database Parameters] database_url = postgres://username:password@hostname:port/dbname

Or can you give an example.

Thankyou again for all your help.

fredcallaway commented 2 months ago

Ah, didn't realize that was a private repo! Here you go https://gist.github.com/fredcallaway/9b8eb28f3ac7539950fee10eb7d53bbb @./0?redirect=https%3A%2F%2Fgist.github.com%2Ffredcallaway%2F9b8eb28f3ac7539950fee10eb7d53bbb&recipient=cmVwbHkrQUI0RVRGR04zNVJaNFNBUVozSVZRRTZFVk9HUk5FVkJOSEhKQTdHR0o0QHJlcGx5LmdpdGh1Yi5jb20%3D) The data will be saved correctly even if you don't update the config file. It gets set on the server by herokuapp.py. Carlos set it up this way so that the config file could be included in a public repo without exposing the data. If you want to use the local psiturk command line, you will to edit the config.txt. In that case make sure not to push the config file to github! On Jul 23 2024, at 3:11 pm, Rohit.K @.> wrote:

Hi there, Thank you for getting back to me. I have a couple of follow-up questions: Broken Link: The link you provided (https://github.com/fredcallaway/webofcash/blob/retention/bin/compensation.py @./1?redirect=https%3A%2F%2Fgithub.com%2Ffredcallaway%2Fwebofcash%2Fblob%2Fretention%2Fbin%2Fcompensation.py&recipient=cmVwbHkrQUI0RVRGR04zNVJaNFNBUVozSVZRRTZFVk9HUk5FVkJOSEhKQTdHR0o0QHJlcGx5LmdpdGh1Yi5jb20%3D)) does not seem to be working. Could you please check the link or provide the correct one? Specifying Database Path in Config File: To ensure the data is saved correctly to the Heroku PostgreSQL database, I would like to confirm if specifying the database URL in the config.txt file as follows is the correct approach: [Database Parameters] database_url = @.:port/dbname

Or can you give an example.

Thankyou again for all your help. — Reply to this email directly, view it on GitHub @./2?redirect=https%3A%2F%2Fgithub.com%2Ffredcallaway%2Fheroku-experiment%2Fissues%2F19%23issuecomment-2245212381&recipient=cmVwbHkrQUI0RVRGR04zNVJaNFNBUVozSVZRRTZFVk9HUk5FVkJOSEhKQTdHR0o0QHJlcGx5LmdpdGh1Yi5jb20%3D), or unsubscribe @./3?redirect=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAB4ETFACWSYR5GIXV7KRLBTZNZJBNAVCNFSM6AAAAABLJNKIIOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBVGIYTEMZYGE&recipient=cmVwbHkrQUI0RVRGR04zNVJaNFNBUVozSVZRRTZFVk9HUk5FVkJOSEhKQTdHR0o0QHJlcGx5LmdpdGh1Yi5jb20%3D). You are receiving this because you commented.

RhtK07 commented 2 months ago

Hi Fred. Thankyou for your message. But using the above code is giving a lots of problem. Especially because how fetch data.py code is written and how it creates the file in data folder.

fredcallaway commented 2 months ago

I'm not sure how to help without knowing exactly what issues you're encountering with fetch_data.py. That script is the only way I ever download data. You should be able to pull out the key code to access the database if you don't like the way it preprocess and saves the data.