Пример #1
0
#! /usr/bin/env python
from traceback import print_exc
from lib.invgame_server.mturk_util import error, connect, mkParser


p = mkParser("Dispose of a HIT")
p.add_argument('--hitids', nargs='+', type=str,
        help='IDs of the HITs to dispose.', required=True)
args = p.parse_args()

try:
    mc = connect(args.credentials_file, args.sandbox)
    for hitid in args.hitids:
        print("Disposing", hitid)
        r = mc.dispose_hit(hitid)
except Exception as e:
    print_exc()
    error("Failed...")
Пример #2
0
#! /usr/bin/env python
from traceback import print_exc
from lib.invgame_server.mturk_util import error, connect, mkParser

p = mkParser("Expire a HIT")
p.add_argument('HITId', type=str, help='ID Of the HIT To expire.')
args = p.parse_args()

try:
    mc = connect(args.credentials_file, args.sandbox)
    r = mc.expire_hit(args.HITId)
except Exception as e:
    print_exc()
    error("Failed...")
Пример #3
0
#! /usr/bin/env python
from traceback import print_exc
from lib.invgame_server.mturk_util import error, connect, mkParser

p = mkParser("Download a file from a question answer")
p.add_argument('AssignmentId', type=str, help='Id of the Assignment.')
p.add_argument('QuestionId', type=str, help='Id of the question.')
args = p.parse_args()

try:
    mc = connect(args.credentials_file, args.sandbox, True)
    r = mc.get_file_upload_url(args.AssignmentId, args.QuestionId)
    print(r[0].FileUploadURL)
except Exception as e:
    print_exc()
    error("Failed...")
#! /usr/bin/env python
from traceback import print_exc
from lib.invgame_server.mturk_util import error, connect, mkParser
from json import loads
from lib.invgame_server.experiments import Experiment, get_event_log_fname

p = mkParser("Process qualification requests")
p.add_argument("qualtype", type=str, help="Qualification Type Identifier");
p.add_argument("--ename", type=str, default='tutorial', \
        help="Experiment name under which the tutorial qualification is " +\
             "running");
args = p.parse_args()

mc = connect(args.credentials_file, args.sandbox)

def getCodes(log_file):
    codes = set()
    for l in open(log_file):
        t = loads(l);
        if (t['method'] == 'getRandomCode'):
            codes.add(t['res'])

    return codes

exp = Experiment(args.ename, True);
codesS = set()

for server_run in exp.server_runs:
    codesS = codesS.union(getCodes(get_event_log_fname(args.ename, \
                                                       server_run.srid)))
Пример #5
0
#! /usr/bin/env python
from argparse import *
from traceback import *
import sys
from boto.mturk.question import *
from boto.mturk.connection import *
from datetime import *
from lib.invgame_server.mturk_util import error, connect, mkParser

p = mkParser("Publish a HIT for playing the game")
args = p.parse_args()

mc = connect(args.credentials_file, args.sandbox)

try:
    balance = mc.get_account_balance()
    print("Balance:", balance[0])
    r = mc.get_all_hits()
    print(
        "Id                             Created              Expires              Review Stat. Status    #Av #C"
    )
    for hit in r:
        print(hit.HITId, hit.CreationTime, hit.Expiration, hit.HITReviewStatus, \
            hit.HITStatus, hit.NumberOfAssignmentsAvailable, " ",\
            hit.NumberOfAssignmentsCompleted)#, hit.Description
except Exception as e:
    print_exc()
    error("Failed...")
Пример #6
0
#! /usr/bin/env python
from traceback import print_exc
from lib.invgame_server.mturk_util import error, connect, mkParser

p = mkParser("List assignments for a hit")
p.add_argument('HITId', type=str, help='HIT Id')
args = p.parse_args()

mc = connect(args.credentials_file, args.sandbox)
try:
    r = mc.get_assignments(args.HITId)
    print("Id                             Accepted             " +\
          "Status               Submited       WorkerId")
    for assn in r:
        print(assn.AssignmentId, assn.AcceptTime, \
              assn.AssignmentStatus, assn.SubmitTime, \
              assn.WorkerId)
except Exception as e:
    print_exc()
    error("Failed...")
Пример #7
0
        r = mc.create_hit(question=q,
                          lifetime=timedelta(7),
                          max_assignments=max_assignments,
                          title=title,
                          description=description,
                          keywords=keywords,
                          reward=HIT_REWARD,
                          duration=timedelta(0, 45*60),
                          qualifications=Qualifications(quals))
        assert len(r) == 1
        print("Created", kind, "HIT", r[0].HITId)
        exp.add_session(ServerRun(srid, r[0].HITId, p.pid, port))
    return exp

if __name__ == "__main__":
    p = mkParser("Run experiment", True)
    p.add_argument('--num_hits', type=int, required=True,
                   help='number of HITs to create')
    p.add_argument('--lvlset', type=str, required=True,
                   help='Lvlset to use for serving benchmarks"')
    p.add_argument('--adminToken', type=str,
                   help='Token to use to login to admin interfaces', required=True)
    p.add_argument('--no-ifs', action='store_const', const=True, default=False,
                   help='Dont teach implication in tutorial or show it ingame')
    p.add_argument('--individual', action='store_true',
                   help='Run in individual mode (levels solved by others don\'t count)')
    p.add_argument('--with-new-var-powerup', action='store_true',
                   help='Enable the new variable powerup')
    p.add_argument('--mode', type=str, default="patterns",
                   help='Game mode to play in. ',
                   choices=["patterns", "ctrex", "rounds"])
Пример #8
0
#! /usr/bin/env python
from lib.invgame_server.mturk_util import connect, hit_status, mkParser, send_notification
from lib.invgame_server.experiments import load_experiment_or_die
import time
import datetime

p = mkParser("Wait for HITs", True)
p.add_argument('--delay', type=int, default = 600, \
        help = "Number of seconds to wait between checks; " +\
               "if none provided, use 600 seconds")
p.add_argument('--email', type=str, required=True,
        help = "Email to notify")
args = p.parse_args()

e = load_experiment_or_die(args.ename)
mc = connect(args.credentials_file, args.sandbox)

notification_subj = "Inv-Game Experiment Notifaction"
previous_num_left = None
while 1:
    print("")
    num_left = hit_status(mc, e, args.sandbox)
    if num_left == 0:
        print("All HITs in this experiment are done")
        send_notification(args.email, notification_subj, \
                "All hits in experiment {0} are done.".format(args.ename))
        exit (0)
    else:
        if previous_num_left != None and previous_num_left != num_left:
            done_in_period = previous_num_left - num_left
            send_notification(args.email, notification_subj,
Пример #9
0
#! /usr/bin/env python
from traceback import print_exc
from lib.invgame_server.mturk_util import error, connect, mkParser

p = mkParser("Disable HIT")
p.add_argument('--hitids',
               nargs='+',
               type=str,
               help='IDs of the HITs to disable.',
               required=True)
args = p.parse_args()

try:
    mc = connect(args.credentials_file, args.sandbox)
    for hitid in args.hitids:
        print("Disabling", hitid)
        r = mc.disable_hit(hitid)
except Exception as e:
    print_exc()
    error("Failed...")
Пример #10
0
#! /usr/bin/env python
from traceback import print_exc
from lib.invgame_server.mturk_util import error, connect, mkParser

p = mkParser("Reject an Assignment")
p.add_argument('AssignmentId', type=str, help='ID Of the Assignment to reject.')
p.add_argument('--feedback', type=str, help='Additional feedback', default=None)
args = p.parse_args()

try:
    mc = connect(args.credentials_file, args.sandbox)
    r = mc.reject_assignment(args.AssignmentId, args.feedback)
except Exception as e:
    print_exc()
    error("Failed...")
Пример #11
0
#! /usr/bin/env python
from lib.invgame_server.mturk_util import mkParser, connect, hit_status
from lib.invgame_server.experiments import load_experiment_or_die
import os
import signal

p = mkParser("Print HIT status", True)
args = p.parse_args()

e = load_experiment_or_die(args.ename)
mc = connect(args.credentials_file, args.sandbox)

hit_status(mc, e, args.sandbox)
Пример #12
0
                          " : FinishLevel without StartLevel")

            if te.event_name == "GameDone":
                if curr_lvl != "":
                    delta = te.time - curr_start
                    print("-- " + curr_lvl + " (interrupted by GameDone): " +\
                            seconds_to_str(delta))


################################################################################
#
# Main processing
#
###############################################################################

p = mkParser("Process logs for experiment", True)
p.add_argument('--pay', action='store_const', const=True, default=False, \
        help='if specified pay workers that need to be payed')
p.add_argument('--nocolor', action='store_const', const=True, default=False, \
        help='if specified do not use colors')

args = p.parse_args()

e = load_experiment_or_die(args.ename)

mc = connect(args.credentials_file, args.sandbox)

for s in e.server_runs:
    print("\n** Server run " + str(s.srid))

    print(bold_green("++ HIT Status"))
Пример #13
0
#! /usr/bin/env python
from traceback import print_exc
from lib.invgame_server.mturk_util import error, connect, mkParser

p = mkParser("Approve an Assignment")
p.add_argument('AssignmentId',
               type=str,
               help='ID Of the Assignment to approve.')
p.add_argument('--feedback',
               type=str,
               help='Additional feedback',
               default=None)
args = p.parse_args()

try:
    mc = connect(args.credentials_file, args.sandbox)
    r = mc.approve_assignment(args.AssignmentId, args.feedback)
except Exception as e:
    print_exc()
    error("Failed...")