Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding easy heroku deployment with ssl support #254

Open
braingineer opened this issue Jan 11, 2017 · 56 comments
Open

adding easy heroku deployment with ssl support #254

braingineer opened this issue Jan 11, 2017 · 56 comments

Comments

@braingineer
Copy link

Hi all,

I've been poking around for some solutions to allow repeated workers. #214 and #90 are the standing reference points. @gureckis mentioned that the ad server might be fussy to get working with allowing repeated workers.

In addition, though, #162 reports wanting a docker image to get things up and running.

To wrap those together, I wanted to drop some bread crumbs. I'm hoping to get to this in mid-February, but I'm ok with anyone wanting to push on it before then. Cog Sci deadline is February 1st and I'm currently working towards that.

The bread crumbs:

  • An automated certbot for deploying Let's Encrypt SSL certs to Heroku: gboudreau/certbot-heroku
  • An example of a one-click deployment implementation: rauchg/slackin
    • Specifically for this one, if you scroll down the repo's readme, there's a Heroku link. Clicking that deploys the implementation.
  • A docker-compose implementation with psiturk: mvdoc/psiturk-docker
@deargle
Copy link
Collaborator

deargle commented Jan 11, 2017

Note to the reader, repeat workers as implemented in #214 will work as long as you're not using the ad server (just set use_psiturk_ad_server = false and point ad_location at heroku, see here ).

I could merge #214 if it is desired, even though it won't work with the ad-server yet.

@suchow
Copy link
Contributor

suchow commented Feb 1, 2017

@braingineer

Regarding Heroku, the SSL certificate is unnecessary because all *.herokuapp.com subdomains are already SSL-enabled.

There are also some changes you'll need to make to psiTurk to get things running on Heroku. In particular, check out the seven most recent commits on https://github.com/suchow/psiTurk-heroku/commits/master. At the time I was testing that, I also created the following instructions, in case they're of any use:

Step 1. Create a Heroku account

Step 2. Install the Heroku toolbelt (https://toolbelt.heroku.com/)

Step 3. Install the custom version of psiTurk (https://github.com/suchow/psiTurk-heroku)

Step 4. Create a copy of the demo app (psiturk-setup-example).

Step 5. Initialize a Git repository inside the demo app (git init)

Step 6. Create a new app using the Heroku toolbelt (heroku create)

Step 7. Add a Postgres database to the Heroku app (heroku addons:create heroku-postgresql)

Step 8. Get the URL of the Postgres database that you have just created (heroku config:get DATABASE_URL)

Step 9. In the demo app, you should see a file config.txt. Replace the database_url (should start with postgresql://) with the URL that you retrieved in Step 8.

Step 10. Set an environment variable with the HOST name (heroku config:set HOST=xyz.herokuapp.com), where xyz is the app name that was printed in Step 6.

Step 11. Set environment variables for your psiTurk and MTurk, replacing XYZ with your access and secret keys:

	heroku config:set psiturk_access_key_id=XYZ
	heroku config:set psiturk_secret_access_id=XYZ
	heroku config:set aws_access_key_id=XYZ
	heroku config:set aws_secret_access_key=XYZ

Step 12. Stage all the files in the demo app (git add .)

Step 13. Commit all the staged files (git commit -m "Initial commit")

Step 14. Launch the app (git push heroku master)

Step 15. Run bash on Heroku (heroku run bash)

Step 16. Run psiTurk from the Heroku bash prompt (psiturk)

Step 17. Create the HIT and answer the questions it asks (hit create), saying yes (y) when it asks if you're using an external process.

Step 18. Go to the sandbox and try out your HIT.

@braingineer
Copy link
Author

Hi @suchow,

Thanks for your work!

So to combine your and @deargle's points:

  • heroku is already SSL enabled,
  • if people aren't using the main ad server, they can deploy HITs that allow for repeat workers

So, then my question is: can Heroku support the custom ad server required to allow for repeat workers? Also, can the ad server be at the same location the experiment is hosted, e.g. can they be on the same Heroku deployment?

Now that primary deadlines have passed, I'm starting to push on this a bit more.

@suchow, your version of psiturk is heroku ready? What's the difference between it and the main branch? Also, would it be compatible with an approach that used the one click deployment buttons?

Best,
Brian

@deargle
Copy link
Collaborator

deargle commented Feb 8, 2017

I can answer these.

if people aren't using the main ad server, they can deploy HITs that allow for repeat workers

Not quite, I haven't merged it yet. But I can.

So, then my question is: can Heroku support the custom ad server required to allow for repeat workers?

Yes, Heroku can serve the ad. There's not actually a custom ad server if you're not using the psiturk ad server. You just have to have regular-old https enabled for your study. If you can run your study in debug mode with https, then you can host your own ad.

I'm guessing here, but Heroku likely has a/several https-enabled web server(s) running in front of all customers' stuff, and those web servers communicate with your individual app server via http. That's fine for mturk's requirements.

Also, can the ad server be at the same location the experiment is hosted, e.g. can they be on the same Heroku deployment?

Yup you can host your own ad in the same location as your experiment.

As an aside, I recommend putting a reverse proxy server like nginx in front of psiturk for performance improvements, but that's not strictly necessary. And I don't have experience doing that with Heroku.

@suchow, your version of psiturk is heroku ready? What's the difference between it and the main branch? Also, would it be compatible with an approach that used the one click deployment buttons?

I looked through and he adds code for reading in several environment variables for things that would normally be read from other files, such as .psiturkconfig. There's also some hacking during the ad creation process for if you're using the psiturk ad server, but I just pushed similar functionality to psiTurk proper called 'adserver_revproxy' which can do the same thing. So the difference will be with reading in via env variables.

Also, would it be compatible with an approach that used the one click deployment buttons?

Not sure about this one.

@braingineer
Copy link
Author

Thanks @deargle!

You just have to have regular-old https enabled for your study.

Aaah. So you're saying the only thing the ad server was allowing for was to let participants see the ad.html, and if you're serving the experiment behind an https connection, then they don't need the redirect?

I recommend putting a reverse proxy server like nginx in front of psiturk for performance improvements

That's a good idea. I'll check into that. I've used things like that before for hiding jupyter notebook servers. I'm also not sure re: heroku, but I'm sure the answer exists somewhere on the internet.

So the difference will be with reading in via env variables.

Ah ok. So there isn't any underlying codebase changes to allow for psiturk to be deployed to heroku, other than the env variables vs psiturkconfig stuff.

one click deployment buttons

poking around quickly before a meeting and I found this example of a post-deployment script. Basically, I think it does mean it can deploy easily, as long as the repo is in a ready-set-go kind of status.

@deargle
Copy link
Collaborator

deargle commented Feb 8, 2017

So you're saying the only thing the ad server was allowing for was to let participants see the ad.html, and if you're serving the experiment behind an https connection, then they don't need the redirect?

That's correct.

BTW, allow_repeats (#214) is now merged into master. Still doesn't work on the psiTurk ad server though.

@gureckis
Copy link
Member

gureckis commented Feb 8, 2017

Going off memory here but I think what the Ad server does is contact your psiTurk process and ask if the worker has completed the task before. If you say yes, it will block them. If you say no it will not. So I think one could change the way psiTurk client works to not block repeats without touching ad server. (I could be wrong... happy to look more deeply at it).

@deargle
Copy link
Collaborator

deargle commented Feb 8, 2017

Hmm interesting. The code in question is right here (socially acceptable to link a private repo in a public comment?)

@deargle
Copy link
Collaborator

deargle commented Feb 8, 2017

Hacking the response status would lose the ability to filter out early quitters, but if that's an acceptable trade-off, yeah it could be done.

@gureckis
Copy link
Member

gureckis commented Feb 8, 2017

Here's he other hint.... to decide to show the ad or an error message the ad server accesses "check_worker_status" route. this returns the status in the database. I think if you turn on "allow repeats" you could simply return a status that would be allowed.

@app.route('/check_worker_status', methods=['GET'])

possible statuses are

Status codes

NOT_ACCEPTED = 0
ALLOCATED = 1
STARTED = 2
COMPLETED = 3
SUBMITTED = 4
CREDITED = 5
QUITEARLY = 6
BONUSED = 7

and status>=SUBMITTED will deny repeat workers

@deargle
Copy link
Collaborator

deargle commented Feb 8, 2017

Oh you're right, no trade-off required.

@gureckis
Copy link
Member

gureckis commented Feb 8, 2017

it would be interesting to force the status to NOT_ACCEPTED or ALLOCATED and see what happens on the ad server. a more clean way would be to pass "allow repeats" to the ad server when you create the ad and then i can add some code to ignore the deny_already_completed_hit code for those ads. this is actually the way the sandbox ad server works (it lets you repeat with same worker info).

@deargle
Copy link
Collaborator

deargle commented Feb 8, 2017

It's easier on the local end to pass you 'allow repeats' during ad creation. I can do that right now... brb

@deargle
Copy link
Collaborator

deargle commented Feb 8, 2017

do you want allow_repeats passed as an int?

@gureckis
Copy link
Member

gureckis commented Feb 8, 2017

however is_sandbox is provided

@deargle
Copy link
Collaborator

deargle commented Feb 8, 2017

Right, it's as an int.

@deargle
Copy link
Collaborator

deargle commented Feb 8, 2017

I'm ready to test, but it's throwing an error until the ad server knows what to do with the passed allow_repeats, so let me know when.

@gureckis
Copy link
Member

gureckis commented Feb 8, 2017

ok, i'm hacking on it now but it won't be a quick as you. tonight or tomorrow.

@deargle
Copy link
Collaborator

deargle commented Feb 8, 2017

No worries, I pushed to a branch.

@gureckis
Copy link
Member

gureckis commented Feb 9, 2017

moving the part of this discussion about repeats to Issue #90

@Yuan-Meng
Copy link

@suchow Sorry to bother you with a silly question, Step 1-15 works perfectly fine for me, but when I entered psiturk in the Heroku bash prompt, the following error occurred:

Traceback (most recent call last): File "/app/.heroku/python/bin/psiturk", line 11, in <module> load_entry_point('PsiTurk', 'console_scripts', 'psiturk')() File "/app/.heroku/src/psiturk/psiturk/command_line.py", line 15, in process launch_shell() File "/app/.heroku/src/psiturk/psiturk/command_line.py", line 101, in launch_shell import psiturk.psiturk_shell as ps File "/app/.heroku/src/psiturk/psiturk/psiturk_shell.py", line 31, in <module> from db import db_session, init_db File "/app/.heroku/src/psiturk/psiturk/db.py", line 27, in <module> engine = create_engine(DATABASE, echo=False, pool_recycle=3600) File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/__init__.py", line 332, in create_engine return strategy.create(*args, **kwargs) File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 48, in create u = url.make_url(name_or_url) File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/url.py", line 164, in make_url return _parse_rfc1738_args(name_or_url) File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/url.py", line 209, in _parse_rfc1738_args return URL(name, **components) File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/url.py", line 59, in __init__ self.port = int(port) ValueError: invalid literal for int() with base 10: ''

I didn't change anything anywhere. Not sure why this would be the case. Thanks!

@deargle
Copy link
Collaborator

deargle commented Feb 27, 2017

Show the config.txt that you pushed?

@deargle
Copy link
Collaborator

deargle commented Feb 27, 2017

Thanks for your work, @suchow. I just set up psiturk proper to work with heroku following the pattern of your fork. Env vars for what would normally go in .psiturkconfig now are respected in psiturk_config.py, so psiturk_shell.py didn't have to be altered except for the improved logging bit.

Changes from your instructions:

  • one new env var (ON_HEROKU)
  • one new config.txt setting (adserver_revproxy_host -- replaces the HOST env var step)
  • hit can be created without needing to run bash on the server (no need to run heroku run bash)

This is compatible with the use_psiturk_ad_server=false functionality.

I've copied your instructions below, with edits.

  1. Create a Heroku account

  2. Install the Heroku toolbelt (https://toolbelt.heroku.com/)

  3. Install psiTurk (install from github until >v2.2.0 is released)

  4. Create a copy of the demo app (psiturk-setup-example). **

  5. Initialize a Git repository inside the demo app (git init)

  6. Create a new app using the Heroku toolbelt (heroku create)

  7. Add a Postgres database to the Heroku app (heroku addons:create heroku-postgresql)

  8. Get the URL of the Postgres database that you have just created (heroku config:get DATABASE_URL)

  9. In the demo app, you should see a file config.txt. Replace the database_url (should start with postgresql://) with the URL that you retrieved in Step 8.

  10. Also in config.txt, if using the psiturk ad server, set adserver_revproxy_host to your heroku domain name. Run heroku domains to see your domain name.

    In config.txt, also do this:

  • host: 0.0.0.0
  • threads: 1

10.5 If not using the psiturk ad server, in config.txt,

use_psiturk_ad_server = false
ad_location = https://your-heroku-domain.herokuapp.com/pub

Use /pub, not /ad, because .com/ad gets blocked by ad blockers

  1. Run the following command to tell your code that it is running on Heroku:
    heroku config:set ON_HEROKU=true.

  2. Set environment variables for your psiTurk and MTurk, replacing XYZ with your access and secret keys:

    heroku config:set psiturk_access_key_id=XYZ
    heroku config:set psiturk_secret_access_id=XYZ
    heroku config:set aws_access_key_id=XYZ
    heroku config:set aws_secret_access_key=XYZ

See this comment for a convenience script for running all 'heroku config:set' commands.

  1. Stage all the files in the demo app (git add .)

  2. Commit all the staged files (git commit -m "Initial commit")

  3. Launch the app (git push heroku master)

  4. Run psiTurk (psiturk)

  5. Create the HIT and answer the questions it asks (hit create), saying yes (y) when it asks if you're using an external process.

  6. Go to the sandbox and try out your HIT.

paging @braingineer to make sure you see this

** If you're starting from a preexisting psiturk app, you need to grab three files from /psiturk/example : requirements.txt, herokuapp.py, and Procfile. Place them in your project root, next to your config.txt.

@braingineer
Copy link
Author

Awesome!! Thanks for the ping!

@braingineer
Copy link
Author

Hey @deargle,

running into some issues with your directions. I have a repo here.

  • it turns out heroku wants more information about that app. before pushing, you need to do:
    heroku buildpacks:set heroku/python
    and have a requirements.txt.
  • the error that @Yuan-Meng got was related to a formatting issue with the revproxy_url in psiturk_shell.py. the fix is:
revproxy_url = "http://{}:{}/ad".format(self.config.get('Server Parameters', 
                                                        'adserver_revproxy_host'),
                                        port)

or, you could just wrap port in an str cast (str(port)).

It might be faster if you push that in, mostly because I think it's in a couple of places. in the meantime, the requirements.txt has a branch of psiturk that only differs on that one thing.

So, those were mostly straight forward to work through. there is one that I'm just not sure about. it has to do with the heroku port and the web server. (also, correct me if I'm wrong, but config.txt needs to be pointing to 0.0.0.0, right?). Essentially, i can create the debug link, but it doesn't work. it says the server is running, but I can't connect. I'm not entirely sure if it's b/c it's actually not running, or if it's b/c heroku is blocking it somehow. or, if it's not using the right port somehow. I guess that last one because when you do the debug -p, it prints out a link with port 80. Not sure if it should be that way.

@braingineer
Copy link
Author

to be more exact about that revproxy_url thing, here's a diff: https://github.com/NYUCCL/psiTurk/compare/master...braingineer:herokusafe?expand=1

@Yuan-Meng
Copy link

Yuan-Meng commented Feb 28, 2017

@deargle
The config.txt in my .git folder (within the psiturk-example folder that I just created) is:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "heroku"]
url = https://git.heroku.com/fast-wildwood-74942.git
fetch = +refs/heads/*:refs/remotes/heroku/*

The config.txt in my psiturk-example folder is:
[HIT Configuration]
title = Stroop task
description = Judge the color of a series of words.
amt_keywords = Perception, Psychology
lifetime = 24
us_only = true
approve_requirement = 95
contact_email_on_error = youremail@gmail.com
ad_group = Default psiTurk Stroop Example
psiturk_keywords = stroop
organization_name = New Great University
browser_exclude_rule = MSIE, mobile, tablet

[Database Parameters]
database_url = postgresql://postgres://...
table_name = turkdemo

[Server Parameters]
host = 0.0.0.0
port = 5000
cutoff_time = 30
logfile = server.log
loglevel = 2
debug = true
login_username = examplename
login_pw = examplepassword
threads = 1
secret_key = 'this is my secret key which is hard to guess, i should change this'
#certfile = <path_to.crt>
#keyfile = <path_to.key>

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

[Shell Parameters]
launch_in_sandbox_mode = true

@deargle
Copy link
Collaborator

deargle commented Feb 28, 2017

Actually @Yuan-Meng's port error was related to sqlalchemy, according to the stack trace. It's because your database_url setting in your config.txt is messed up. drop that second postgresql://.

And @braingineer I forgot to make something clear -- my instructions assume that you do in fact start from psiturk-setup-example. There are three new files that are copied into the default example that heroku needs -- requirements.txt, Procfile, and herokuapp.py. And yes, you need to change host to 0.0.0.0 in config.txt.

And @suchow changed threads from auto to 1 in his code. I tested with that change too. Probably heroku will explode if more threads are attempted. Haven't tried yet. I'll go back and update the instructions in my first post.

So, those were mostly straight forward to work through. there is one that I'm just not sure about. it has to do with the heroku port and the web server. (also, correct me if I'm wrong, but config.txt needs to be pointing to 0.0.0.0, right?). Essentially, i can create the debug link, but it doesn't work. it says the server is running, but I can't connect. I'm not entirely sure if it's b/c it's actually not running, or if it's b/c heroku is blocking it somehow. or, if it's not using the right port somehow. I guess that last one because when you do the debug -p, it prints out a link with port 80. Not sure if it should be that way.

Once you have Procfile in place, it should actually launch the server and you should be able to connect. When you deploy to heroku, it executes Procfile which execute herokuapp.py which directly launches the psiturk server, bound to whatever port heroku wants it to. Then to debug, you visit <your.heroku.domain> on plain 'ol port 80, which heroku redirects to the automagically-launched psiturk server, again, bound on whatever port it gave it. port in config.txt is ignored on the server.

@braingineer
Copy link
Author

@deargle hmm. I might have run the psiturk-setup-example before I re-pulled the branch to get the newer updates because my repo was initialized with it just earlier this evening. I'll be sure to redo that then!

re: everything else.
gotcha! thanks. will report if other issues. thanks!

@deargle
Copy link
Collaborator

deargle commented Feb 28, 2017

@braingineer, were you experiencing an error with the port casting independent of @Yuan-Meng?

@deargle
Copy link
Collaborator

deargle commented Feb 28, 2017

Sorry, silly question, I see now. I just couldn't imagine why my tests didn't catch that. I suppose I've always had adserver_revproxy_port set, so I never hit that casting issue. Thanks for the report.

@Yuan-Meng
Copy link

@braingineer I'm curious if you're using the custom version of psiTurk created by @suchow or the default version. I asked this because in the custom version, there's no revproxy_url in psiturk_shell.py.

@deargle
Copy link
Collaborator

deargle commented Feb 28, 2017

He's using psiturk proper, with the code I just pushed earlier today. BTW I just pushed a fix to master fixing the debug -p issue.

@Yuan-Meng It just dawned on me that you'll want to edit the database_url out of your post above, because it contains a username:password

@Yuan-Meng
Copy link

Yuan-Meng commented Feb 28, 2017

@deargle Ah, thank you!

After dropping postgresql://, I'm finally able to launch psiTurk shell (using @suchow 's psiTurk-heroku and the Heroku bash prompt).

However, (someone may have mentioned this) I'm facing a new issue now--I can't open the debug link that I was given.

Also, I created a HIT and the Ad URL led me to "Error: 1018 (Description: The requested HIT is not registered with the psiTurk ad server.)"

I forgot to mention that there's something that works--the MTurk URL--I'm able to do my example task as a worker. This makes me wonder what's wrong with my debug and Ad links.

@deargle
Copy link
Collaborator

deargle commented Feb 28, 2017 via email

@Yuan-Meng
Copy link

Yuan-Meng commented Feb 28, 2017

@deargle

  1. About the debug link:

Did you pull from master within the last hour?

Yes. In fact, I went through all required steps within a few minutes.

  1. About the 1018 error:

psiturk credentials aren't set correctly on heroku...

Below is what I typed in terminal when setting env vars:
heroku config:set psiturk_access_key_id=5B...3i
heroku config:set psiturk_secret_access_id=KJ...Ho
heroku config:set aws_access_key_id=AK...4A
heroku config:set aws_secret_access_key=5d...od
I doubled checked if I entered the correct keys and I did.

(update)
3. Using the procedure that you wrote for psiTurk proper (I copied requirement.txt and psiturkapp.py [didn't find herokuapp.py, though] from another folder I created with psiTurk-heroku), I can debug now. However, the Ad URL has a new error-- Error #1015 (Sorry, the experiment server is currently unreachable.). I should mention that although I followed the psiTurk proper procedure, I didn't uninstall psiTurk-heroku. Maybe that's problematic.

@deargle
Copy link
Collaborator

deargle commented Feb 28, 2017

@Yuan-Meng @braingineer I just released a new version of psiturk to pip (v2.2.1) so that when heroku installs via requirements.txt, it actually works. The version of requirements.txt that I bundled with the example app references an unpinned PsiTurk, so it should pick up the version bump. Heroku needs the updates in 2.2.1. Sorry about that, forgot that not bumping would lead to issues -- my version of requirements.txt that I was testing against was installing off of github master, not pip.

So if you were having troubles, try rebuilding your heroku app.

@Yuan-Meng
Copy link

Yuan-Meng commented Feb 28, 2017

@deargle Thanks for the new version!

It's strange that I'm keeping getting Error #1018 (The requested HIT is not registered with the psiTurk ad server.)--I even regenerated my psiTurk keys and AMS keys and checked many times that I entered the correct new keys.

I also don't think there were typos when I set env vars: (digits in the middle are replaced with ...)
heroku config:set psiturk_access_key_id=vGB...jz3
heroku config:set psiturk_secret_access_id=5EJ...ghW
heroku config:set aws_access_key_id=AKI...Y6A
heroku config:set aws_secret_access_key=xql...Glv

Are there any other possible reasons for Error #1018?

Update #1: I saw Todd Gurekis's answer a couple of years ago. He said:

I suspect you are trying to run the full task through the new links that Jay added to the “create hit” prompt. The problem with accessing the task directly on the ad server is that your “hitId” is set to a bogus value...
Bottom line, use ‘debug’ command to test everything locally. At the next stage, access directly on the worker sandbox site to do anything besides simply look at the ad.
The technical reason is that when you begin the experiment, psiturk uses the hitId to lookup you
ad. When the hitId is bogus the lookup fails and you get at 1018 error because the bogus hit
is not registered with the ad server.

Update #2:
I also saw your answer from last year:

you can't test sandbox experiments using the https://sandbox.ad.psiturk.org/view/ link given to you when you create the hit. You can test your sandboxed hit by:

  • finding your hit on https://workersandbox.mturk.com/mturk/welcome
  • requesting a debug url using debug -p (skipping the psiturk ad server entirely)
  • if you installed off of @master, you can visit your root url ip:port and the "begin by viewing the ad" button will generate a url same as would debug -p

Just to be sure, when we create a HIT in the sandbox mode, we're actually not supposed (to be able) to open the Ad URL, right? Only in the live mode can we open that link?

Thanks!

@deargle
Copy link
Collaborator

deargle commented Feb 28, 2017

Yes, everything in your two updates is true. Forgot about that, sorry for the goose chase.

Maybe we should make this note below the generated url more prominent: "Note: This url cannot be used to run your full psiTurk experiment. It is only for testing your ad."

There's another way you can bypass that ad server lookup: on the 1018 error page, change 'mode=sandbox' to 'mode=debug' in the url.

if you installed off of @master, you can visit your root url ip:port and the "begin by viewing the ad" button will generate a url same as would debug -p

You no longer need to install off of master for this to work.

@deargle
Copy link
Collaborator

deargle commented May 31, 2017

Here's a quick way to set the four heroku configs:

from psiturk.psiturk_config import PsiturkConfig
import subprocess

CONFIG = PsiturkConfig()
CONFIG.load_config()

sections = ['psiTurk Access','AWS Access']
for section in sections:
    for item in CONFIG.items(section):
        #print 'heroku config:set ' + '='.join(item)
        subprocess.call('heroku config:set ' + '='.join(item), shell=True)

subprocess.call('heroku config:set ON_HEROKU=true', shell=True)

@fredcallaway
Copy link
Contributor

fredcallaway commented Feb 6, 2018

Following @deargle's instructions, I got a psycogp error (see #299) pushing to heroku.

I solved it by removing the ==2.6.2 from requirements.txt, so it now reads

PsiTurk
psycopg2

@deargle
Copy link
Collaborator

deargle commented Feb 6, 2018

@fredcallaway odd that it works for me still, but yeah psycopg/psycopg2#594 says 2.7.1 works.

@fredcallaway
Copy link
Contributor

Haha looks like you beat me to the pull request ;)

@deargle
Copy link
Collaborator

deargle commented Feb 6, 2018

I'm ultra fast when I can just use the github gui to make changes ;-)

@Speldosa
Copy link
Contributor

Speldosa commented Apr 1, 2018

I've created a pull request (#311) where I've written up some of the information on how to use psiTurk with Heroku. I'm thinking about maybe looking into creating a Python script that sets up everything for you. However, here there seems to be some discussion regarding automatically setting up your own ad server on Heroku as well, something that I'm not familiar with how you would do.

If somebody more experienced would like to lead the way, I could help out creating the more mundane parts of the script. Otherwise, I might just go ahead and just create what I can handle right now.

@deargle
Copy link
Collaborator

deargle commented Apr 1, 2018 via email

@Speldosa
Copy link
Contributor

Speldosa commented Apr 1, 2018

Oh, I thought the process was more complicated. Well, I'll try that out and add it to the documentation. I should be able to write the setup script myself then.

@abardon
Copy link

abardon commented Jul 26, 2019

When using Heroku, no data seems to be saved to my postgres database. When just hosting locally, data is recorded properly to the local participants.db. When I follow the steps to setup heroku and then run a trial, the download_datafiles command no longer finds any data in my postgres database. The trial is recorded, but there is no data. Any suggestions?

@deargle
Copy link
Collaborator

deargle commented Jul 26, 2019 via email

@abardon
Copy link

abardon commented Jul 26, 2019

Is that the "heroku config:set ON_HEROKU=true" command? I ran that when setting it up, but still can't use download_datafiles.

@deargle
Copy link
Collaborator

deargle commented Jul 26, 2019

I haven't used the download_datafiles command in... ever. Why do you think that no data is being saved? If you log into the db (heroku psql), is there data there? And have you updated your database_url in your local config.txt to point to the postgresql db? If you haven't, then I don't think that download_datafiles would find anything, because it wouldn't be looking in the right place.

@abardon
Copy link

abardon commented Jul 26, 2019

I did update config.txt. The datastring in the postgresql db is just a very long unreadable string of letters and numbers, unlike the one that saved in my participants.db before which was a very long string of all the data in the format that I specified. I'm not sure if it has been written correctly?

@deargle
Copy link
Collaborator

deargle commented Jul 26, 2019

It's long because it includes your heroku-supplied username:password. sqlite doesn't have authentication, so therefore shorter.

Have you logged in to check yet?

@abardon
Copy link

abardon commented Jul 26, 2019

I'm looking at the database in postico, and the datastring doesn't have the data that i wrote with psiTurk.recordTrialData() anywhere in it. Is this an ok way to look at it?

@tianweigong
Copy link

tianweigong commented Jul 27, 2019

I'm looking at the database in postico, and the datastring doesn't have the data that i wrote with psiTurk.recordTrialData() anywhere in it. Is this an ok way to look at it?

2019.7.27
I have a similar problem here. I used the stroop example. All procedure in sandbox went right but finally there was no data in the heroku database.( If I run download_datafiles, there would be "('No trial data found in record:', Subject(uniqueid|A3I6Y8407JIPA1:354P56DE9L689F2BRQ3YPQSRHSSS7B, condition|0, status|4, codeversion|1.0)) -- subject id ✔ data ✘.

2019.7.29
After exporting my "heroku psql", I found the data seemed to be there (it increased with the completed hit sizes) but unreadable (garbled). Even when I just built the heroku ("git push heroku master" for the first time), there had been some unreadable things at the end of the database. I think it is an encoding problem, which might already happen before the data collection. Any suggestion could be really helpful. Thanks!

@deargle
Copy link
Collaborator

deargle commented Jul 29, 2019

Going forward, let's create new issues for heroku-related problems. I'm going to look at the datastring issue rn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants