How to use the psiturk.psiturk_config.PsiturkConfig function in PsiTurk

To help you get started, we’ve selected a few PsiTurk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NYUCCL / psiTurk / tests / test_psiturk_shell.py View on Github external
def do_it():
        from psiturk.psiturk_shell import PsiturkNetworkShell
        import psiturk.experiment_server_controller as control
        from psiturk.psiturk_config import PsiturkConfig
        
        import psiturk.experiment_server_controller
        mocker.patch.object(psiturk.experiment_server_controller.ExperimentServerController, 'is_port_available', lambda *args, **kwargs: True)
        
        mocker.patch.object(PsiturkNetworkShell,'get_intro_prompt', lambda *args, **kwargs: '')
        mocker.patch.object(PsiturkNetworkShell,'update_hit_tally', lambda *args, **kwargs: None)
        mocker.patch.object(PsiturkNetworkShell,'_confirm_dialog', lambda *args, **kwargs: True)

        config = PsiturkConfig()
        config.load_config()
        server = control.ExperimentServerController(config)

        launch_in_sandbox_mode = True
        quiet = False
        shell = PsiturkNetworkShell(
            config, server,
            launch_in_sandbox_mode,
            quiet=quiet)
        shell.persistent_history_file = None
        shell.echo = True
        stubber.assert_no_pending_responses()
        return shell
github NYUCCL / psiTurk / tests / test_noaws.py View on Github external
def test_awscreds_notset(capfd, experiment_server_controller, psiturk_shell):
    from psiturk.psiturk_config import PsiturkConfig
    from psiturk.psiturk_shell import PsiturkNetworkShell
    import psiturk.psiturk_shell as ps
    import psiturk.experiment_server_controller
    
    config = PsiturkConfig()
    config.load_config()
    config.set('Shell Parameters', 'persistent_history_file', '')
    config.set('AWS Access','aws_access_key_id', 'YourAccessKeyId')
    config.set('AWS Access','aws_secret_access_key', 'YourSecretAccessKey')
    
    server = psiturk.experiment_server_controller.ExperimentServerController(config)

    launch_in_sandbox_mode = True
    quiet = False
    try:
        shell = PsiturkNetworkShell(
            config, server,
            launch_in_sandbox_mode,
            quiet=quiet)
    except SystemExit:
        pass
github Dallinger / Dallinger / wallace / command_line.py View on Github external
ensure_heroku_logged_in()

    # Change to temporary directory.
    cwd = os.getcwd()
    os.chdir(tmp)

    # Commit Heroku-specific files to tmp folder's git repo.
    cmds = ["git init",
            "git add --all",
            'git commit -m "Experiment ' + id + '"']
    for cmd in cmds:
        subprocess.call(cmd, stdout=OUT, shell=True)
        time.sleep(0.5)

    # Load psiTurk configuration.
    config = PsiturkConfig()
    config.load_config()

    # Initialize the app on Heroku.
    log("Initializing app on Heroku...")
    subprocess.call(
        "heroku apps:create " + id +
        " --buildpack https://github.com/thenovices/heroku-buildpack-scipy",
        stdout=OUT,
        shell=True)

    # Set up postgres database and AWS/psiTurk environment variables.
    cmds = [
        "heroku addons:create heroku-postgresql:standard-0",

        "heroku pg:wait",
github Dallinger / Dallinger / examples / bartlett1932 / custom.py View on Github external
abort, current_app
from jinja2 import TemplateNotFound

from psiturk.psiturk_config import PsiturkConfig
from psiturk.experiment_errors import ExperimentError
from psiturk.user_utils import PsiTurkAuthorization

# # Database setup
from psiturk.db import db_session
from psiturk.models import Participant
from json import dumps, loads

from wallace import db, agents, models

# load the configuration options
config = PsiturkConfig()
config.load_config()
myauth = PsiTurkAuthorization(config)

# explore the Blueprint
custom_code = Blueprint(
    'custom_code', __name__,
    template_folder='templates',
    static_folder='static')

# Initialize the Wallace db
db_session_w = db.init_db(drop_all=False)

# Specify the experiment.
try:
    this_experiment = config.get('Experiment Configuration', 'experiment')
    mod = __import__('custom_experiments', fromlist=[this_experiment])
github NYUCCL / psiTurk / psiturk / dashboard / __init__.py View on Github external
from psiturk.psiturk_config import PsiturkConfig
from psiturk.experiment_errors import ExperimentError, InvalidUsage
from psiturk.user_utils import PsiTurkAuthorization, nocache
from psiturk.models import Participant
from psiturk.psiturk_exceptions import *

from psiturk.services_manager import psiturk_services_manager as services_manager

# # Database setup
from psiturk.db import db_session, init_db
from psiturk.models import Participant
from json import dumps, loads

# load the configuration options
config = PsiturkConfig()
config.load_config()
# if you want to add a password protect route use this
myauth = PsiTurkAuthorization(config)

# import the Blueprint
dashboard = Blueprint('dashboard', __name__,
                        template_folder='templates', static_folder='static', url_prefix='/dashboard')       

from psiturk.experiment import app
from flask_login import LoginManager, UserMixin
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'dashboard.login'

class DashboardUser(UserMixin):
    def __init__(self, username=''):
github NYUCCL / psiTurk / psiturk / experiment_server.py View on Github external
from __future__ import print_function
from __future__ import absolute_import
# myapp.mycustomapplication
from builtins import str
from gunicorn.app.base import Application
from gunicorn import util
import multiprocessing
from psiturk.psiturk_config import PsiturkConfig
import os
import hashlib

config = PsiturkConfig()
config.load_config()


class ExperimentServer(Application):
    '''
    Custom Gunicorn Server Application that serves up the Experiment application
    '''

    def __init__(self):
        '''__init__ method
        Load the base config and assign some core attributes.
        '''
        self.load_user_config()
        self.usage = None
        self.callable = None
        self.options = self.user_options
github Dallinger / Dallinger / examples / translations / custom.py View on Github external
from psiturk.psiturk_config import PsiturkConfig
from psiturk.experiment_errors import ExperimentError
from psiturk.user_utils import PsiTurkAuthorization, nocache

# # Database setup
from psiturk.db import db_session, init_db
from psiturk.models import Participant
from json import dumps, loads

from wallace import db, experiments, agents, models, networks, processes

import os

# load the configuration options
config = PsiturkConfig()
config.load_config()
myauth = PsiTurkAuthorization(config)

# explore the Blueprint
custom_code = Blueprint(
    'custom_code', __name__,
    template_folder='templates',
    static_folder='static')

# Initialize the Wallace db
db_session_w = db.init_db(drop_all=False)

# Specify the experiment.
try:
    this_experiment = config.get('Experiment Configuration', 'experiment')
    mod = __import__('custom_experiments', fromlist=[this_experiment])
github Dallinger / Dallinger / wallace / command_line.py View on Github external
def setup(debug=True, verbose=False):
    """Check the app and, if it's compatible with Wallace, freeze its state."""
    print_header()

    # Verify that the package is usable.
    log("Verifying that directory is compatible with Wallace...")
    if not verify_package(verbose=verbose):
        raise AssertionError(
            "This is not a valid Wallace app. " +
            "Fix the errors and then try running 'wallace verify'.")

    # Load psiTurk configuration.
    config = PsiturkConfig()
    config.load_config()

    # Check that the version of Wallace specified in the config file is the one
    # that we are currently running.
    wallace_version = config.get('Experiment Configuration', 'wallace_version')
    this_version = pkg_resources.require("wallace")[0].version
    if wallace_version != this_version:
        raise AssertionError(
            "You are using Wallace v" + this_version + ", "
            "but the experiment requires v" + wallace_version)

    # Generate a unique id for this experiment.
    id = "w" + str(uuid.uuid4())[0:28]
    log("Running as experiment " + id + "...")

    # Copy this directory into a temporary folder, ignoring .git