-
Notifications
You must be signed in to change notification settings - Fork 141
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
Comments
Regarding Heroku, the SSL certificate is unnecessary because all 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:
|
Hi @suchow, Thanks for your work! So to combine your and @deargle's points:
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, |
I can answer these.
Not quite, I haven't merged it yet. But I can.
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.
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.
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.
Not sure about this one. |
Thanks @deargle!
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?
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.
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.
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. |
That's correct. BTW, allow_repeats (#214) is now merged into master. Still doesn't work on the psiTurk ad server though. |
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). |
Hmm interesting. The code in question is right here (socially acceptable to link a private repo in a public comment?) |
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. |
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. Line 180 in d00b571
possible statuses are Status codesNOT_ACCEPTED = 0 and status>=SUBMITTED will deny repeat workers |
Oh you're right, no trade-off required. |
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). |
It's easier on the local end to pass you 'allow repeats' during ad creation. I can do that right now... brb |
do you want |
however |
Right, it's as an int. |
I'm ready to test, but it's throwing an error until the ad server knows what to do with the passed |
ok, i'm hacking on it now but it won't be a quick as you. tonight or tomorrow. |
No worries, I pushed to a branch. |
moving the part of this discussion about repeats to Issue #90 |
@suchow Sorry to bother you with a silly question, Step 1-15 works perfectly fine for me, but when I entered
I didn't change anything anywhere. Not sure why this would be the case. Thanks! |
Show the config.txt that you pushed? |
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 Changes from your instructions:
This is compatible with the I've copied your instructions below, with edits.
10.5 If not using the psiturk ad server, in config.txt,
Use
See this comment for a convenience script for running all 'heroku config:set' commands.
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 : |
Awesome!! Thanks for the ping! |
Hey @deargle, running into some issues with your directions. I have a repo here.
or, you could just wrap It might be faster if you push that in, mostly because I think it's in a couple of places. in the meantime, the 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 |
to be more exact about that |
@deargle The [Database Parameters] [Server Parameters] [Task Parameters] [Shell Parameters] |
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 And @braingineer I forgot to make something clear -- my instructions assume that you do in fact start from And @suchow changed
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. |
@deargle hmm. I might have run the re: everything else. |
@braingineer, were you experiencing an error with the port casting independent of @Yuan-Meng? |
Sorry, silly question, I see now. I just couldn't imagine why my tests didn't catch that. I suppose I've always had |
@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 |
He's using psiturk proper, with the code I just pushed earlier today. BTW I just pushed a fix to master fixing the @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 |
@deargle Ah, thank you! After dropping 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. |
it seems I can't open the debug link that I was given
Need more information. Did you pull from master within the last hour?
"Error: 1018 (Description: The requested HIT is not registered with the
psiTurk ad server.)"
In this case, that's an inaccurate error message description. The problem
is that your psiturk credentials aren't set correctly on heroku. Check to
make sure that you set the env vars correctly in this step:
```
heroku config:set psiturk_access_key_id=XYZ
heroku config:set psiturk_secret_access_id=XYZ
```
Make sure you didn't put quotes around your values. Maybe share the results
of `heroku config`, trimming the middle of the keys, just so we see that
you didn't typo something.
EDIT: just saw your edits to your "can't open the debug link". I suspect that you haven't set `adserver_revproxy_host`? If you had, you wouldn't be getting debug links with 0.0.0.0 in them. That would be substituted with whatever value `adserver_revproxy_host` has.
EDIT 2: just saw that you're still on suchow's fork, following his instructions. Let me know once you're back on psiturk proper.
…On Mon, Feb 27, 2017 at 9:03 PM Yuan Meng ***@***.***> wrote:
@deargle <https://github.com/deargle> Ah, thank you!
After dropping postgresql://, I'm finally able to launch psiTurk shell.
However, (someone may have mentioned this) it seems I can't open the debug
link that I was given. Also, I created a HIT and the
https://sandbox.ad.psiturk.org/view/gqUTR6xBdXNFTtzoBgSt6f?assignmentId=debugQDN486&hitId=debugAYHDZZ&workerId=debug27EHFJ
led me to "Error: 1018 (Description: The requested HIT is not registered
with the psiTurk ad server.)"
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#254 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABHsfX4Mpkck_koSXRwDhoQ8Da5U8pemks5rg4BjgaJpZM4Lgtrh>
.
|
Yes. In fact, I went through all required steps within a few minutes.
Below is what I typed in terminal when setting env vars: (update) |
@Yuan-Meng @braingineer I just released a new version of psiturk to pip (v2.2.1) so that when heroku installs via So if you were having troubles, try rebuilding your heroku app. |
@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 ...) Are there any other possible reasons for Error #1018? Update #1: I saw Todd Gurekis's answer a couple of years ago. He said:
Update #2:
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! |
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.
You no longer need to install off of master for this to work. |
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 odd that it works for me still, but yeah psycopg/psycopg2#594 says 2.7.1 works. |
Haha looks like you beat me to the pull request ;) |
I'm ultra fast when I can just use the github gui to make changes ;-) |
I've created a pull request (#311) where I've written up some of the information on how to use 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. |
It's not "set up your own ad server" -- rather, it's "host your own ad
using the same server that runs your psiturk experiment instead of relying
on the psiturk ad server". It's as simple as telling mturk that the
location of your ad is `https://<your heroku domain>/pub`. /pub is a
synonym for /ad, where /pub is used instead to avoid ad blockers.
To switch psiturk to not use the psiturk ad server, you just set the last
two config options to `false` and the `route to your heroku domain /pub`
respectively.
…On Sun, Apr 1, 2018, 4:16 PM Martin Asperholm ***@***.***> wrote:
I've created a pull request (#311
<#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.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#254 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABHsfRBsP3rgP8uE70jmCfGkCDjEG2lzks5tkVG2gaJpZM4Lgtrh>
.
|
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. |
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? |
Likely you did not set ON HEROKU env var, so it is not using the postgres
db, and it is saving to a local, inaccessible sqlite db.
…On Fri, Jul 26, 2019, 10:02 AM abardon ***@***.***> wrote:
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. Any suggestions?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#254?email_source=notifications&email_token=AAI6Y7J2QCQW5VDPSQUTJNDQBMNYZA5CNFSM4C4C3LQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD25AYYA#issuecomment-515509344>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAI6Y7LEZ5VUT4FJIICHMWTQBMNYZANCNFSM4C4C3LQQ>
.
|
Is that the "heroku config:set ON_HEROKU=true" command? I ran that when setting it up, but still can't use download_datafiles. |
I haven't used the |
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? |
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? |
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 2019.7.29 |
Going forward, let's create new issues for heroku-related problems. I'm going to look at the datastring issue rn. |
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:
The text was updated successfully, but these errors were encountered: