def create_hit(task_settings, conn=None, url=settings.URL): """ Create a hit on mturk with @question in a @batch using @mturk_connection """ assert "Title" in task_settings assert "Description" in task_settings assert "MaxAssignments" in task_settings assert "Reward" in task_settings assert "AssignmentDurationInSeconds" in task_settings assert "LifetimeInSeconds" in task_settings if conn is None: conn = _CONN logger.debug("Creating HIT") question = ExternalQuestion(url, task_settings.get("FrameHeight", 800)) response = conn.create_hit(Question=question.get_as_xml(), Title=task_settings["Title"], Description=task_settings["Description"], MaxAssignments=task_settings["MaxAssignments"], AssignmentDurationInSeconds=task_settings["AssignmentDurationInSeconds"], LifetimeInSeconds=task_settings["LifetimeInSeconds"], Reward=task_settings["Reward"], QualificationRequirements=task_settings.get("QualificationRequirements"), ) logger.debug("HIT created (%s, %s).", response['HIT']['HITTypeId'], response['HIT']['HITId']) return response['HIT']
def create_hit(conn, frame_height=None, title=None, description=None, max_assignments=None, duration=None, lifetime=None, reward=None, **kwargs): """ Create a hit on mturk with @question in a @batch using @mturk_connection """ logger.debug("Creating HIT(%s)", title) question = ExternalQuestion(MTURK_URL, frame_height) response = conn.create_hit(Question=question.get_as_xml(), Title=title, Description=description, MaxAssignments=int(max_assignments), AssignmentDurationInSeconds=int(duration), LifetimeInSeconds=int(lifetime), Reward=reward) logger.debug([ "HIT created: ", response['HIT']['HITTypeId'], response['HIT']['HITId'] ]) return response['HIT']['HITTypeId'], response['HIT']['HITId']
def create_hits(self, num_hits, configuration=None, hit_type_id=None): """ Create `num_audio_hits` according to the parameters specified in `hit_params` Parameters ---------- num_hits: int configuration: dict hit_type_id: int, optional Returns ------- None """ if configuration is None: configuration = app.config if hit_type_id is None: hit_type_id = self.hit_type_id question = ExternalQuestion( configuration['MTURK_QUESTION_URL'], frame_height=configuration['MTURK_FRAME_HEIGHT']) for _i in range(num_hits): self.connection.create_hit_with_hit_type( HITTypeId=hit_type_id, MaxAssignments=configuration['MTURK_MAX_ASSIGNMENTS'], LifetimeInSeconds=configuration['MTURK_LIFETIME_IN_SECONDS'], Question=question.get_as_xml())
def create_task(client): question = ExternalQuestion(os.environ['HEROKU_URL'], frame_height=540) new_hit = client.create_hit( Title='Finish the game (Move with WASD or arrow keys).', Description='It might take approximately 30 secs to load the page.', Keywords='question, answer, research, game, grid', Reward='0.15', MaxAssignments=100, LifetimeInSeconds=172800, AssignmentDurationInSeconds=1200, AutoApprovalDelayInSeconds=14400, Question=question.get_as_xml(), # <--- this does the trick ) print("HITID = " + new_hit['HIT']['HITId'])
def create_hit(treatment, max_assignment=12, frame_height=800, reward=0.5, sandbox=True): url = f"https://tube.ddns.net/start/{treatment}/?adapter=mturk" # <-- this is my website mturk = get_mturk_client(sandbox) qualificationRequirements = [ { "QualificationTypeId": "000000000000000000L0", "Comparator": "GreaterThanOrEqualTo", "IntegerValues": [80], "RequiredToPreview": False, "ActionsGuarded": "Accept" }, { "QualificationTypeId": "00000000000000000071", "Comparator": "EqualTo", "LocaleValues": [{ "Country": "US" }], "RequiredToPreview": False, "ActionsGuarded": "Accept" }, ] if sandbox: qualificationRequirements = [] question = ExternalQuestion(url, frame_height=frame_height) new_hit = mturk.create_hit( Title='The Ultimatum Bargaining Experiment', Description= 'Take part on an intresting experiment about human behaviour', Keywords='survey, bargaining, experiment', Reward='0.5', MaxAssignments=max_assignment, LifetimeInSeconds=7 * 24 * 3600, AssignmentDurationInSeconds=60 * 30, AutoApprovalDelayInSeconds=6 * 24 * 3600, Question=question.get_as_xml(), # <--- this does the trick QualificationRequirements=qualificationRequirements, ) click.echo(f"New hit created: {new_hit}") return new_hit
def create_hit(hit_type, URL, num_of_assignments): title = title_set[hit_type] description = description_set[hit_type] keywords = keywords_set[hit_type] reward = price_set[hit_type] print(mturk.get_account_balance()) # Old Qualification # qualifications = Qualifications() # qualifications.add(NumberHitsApprovedRequirement("GreaterThanOrEqualTo", approve_num_hit)) # qualifications.add(PercentAssignmentsApprovedRequirement("GreaterThanOrEqualTo", approve_requirement)) # qualifications.add(LocaleRequirement("EqualTo", "US")) # qualifications.add(LocaleRequirement("In", ['US', 'GB', 'IN'], required_to_preview=True)) qualifications = [ # { # 'QualificationTypeId': '00000000000000000071', #Worker_Locale # 'Comparator': 'In', # 'LocaleValues': [ # { # 'Country': "US" # }, # { # 'Country': "GB" # } # ], # 'RequiredToPreview': True # }, { 'QualificationTypeId': '00000000000000000040', #Worker_​NumberHITsApproved 'Comparator': 'GreaterThanOrEqualTo', 'IntegerValues': [approve_requirement] }, { 'QualificationTypeId': '000000000000000000L0', #Worker_​PercentAssignmentsApproved 'Comparator': 'GreaterThanOrEqualTo', 'IntegerValues': [approve_requirement] } ] questionform = ExternalQuestion(external_url=URL, frame_height=frame_height) # create HIT # create_hit_result = mturk.create_hit( # title=title, # description=description, # keywords=keywords, # question=questionform, # reward=reward, # qualifications=qualifications, # duration=duration, # max_assignments=num_of_assignments, # lifetime=lifetime, # approval_delay=approval_delay # #response_groups = ( 'Minimal', 'HITDetail' ), # I don't know what response groups are # ) create_hit_result = mturk.create_hit( MaxAssignments=num_of_assignments, AutoApprovalDelayInSeconds=approval_delay, LifetimeInSeconds=lifetime, AssignmentDurationInSeconds=duration, Reward=str(reward), Title=title, Keywords=keywords, Description=description, Question=questionform.get_as_xml(), QualificationRequirements=qualifications) HIT = create_hit_result['HIT'] print('[create_hit( %s, $%s ): %s]' % (URL, reward, HIT["HITId"])) print(HIT["HITId"]) return HIT["HITId"]
'Country': 'string', 'Subdivision': 'string' }, ], 'RequiredToPreview': True|False, 'ActionsGuarded': 'Accept'|'PreviewAndAccept'|'DiscoverPreviewAndAccept' },''' for i in range(2, 10): part = i base_url = "https://lia.epfl.ch/emotionrecog/" + str(part) encoded_url = encode_get_parameters(base_url, params_to_encode) print(encoded_url) question = ExternalQuestion(encoded_url, HIT["FrameHeight"]) question_xml = question.get_as_xml() print(question_xml) new_hit = client.create_hit( MaxAssignments=HIT["MaxAssignments"], AutoApprovalDelayInSeconds=HIT["AutoApprovalDelayInSeconds"], LifetimeInSeconds=HIT["LifetimeInSeconds"], AssignmentDurationInSeconds=HIT["AssignmentDurationInSeconds"], Reward=HIT["Reward"], Title=HIT['Title'], Keywords=HIT["Keywords"], Description=HIT["Description"], Question=question_xml, RequesterAnnotation='PART:' + str(part), QualificationRequirements=[ {
def PostHits(pay, lifetime, max_assignments, exp): region_name = 'us-east-1' keywords = 'attention, psychology, experiment, research' title = 'A Decision Making Experiment' experimentName = 'Decision Making Experiment' ## this is NOT what it ends up getting called on my server description = 'This HIT will take between 30-40 mins to complete. All HITS in this batch are the same, and you will only be able to perform one of the HITS in this batch.' ## PRODUCTION LINK #q = ExternalQuestion(external_url = "https://davebraun.org/dissertation/experiments/production/" + exp +"/", frame_height=675) ## MAKE UP HIT LINK q = ExternalQuestion( external_url= "https://davebraun.org/dissertation/experiments/production/makeupHit", frame_height=675) ## EXP 3 PILOT #q = ExternalQuestion(external_url = "https://davebraun.org/dissertation/experiments/production/pilots/exp3Pilot/", frame_height=675) qr = [{ 'QualificationTypeId': '000000000000000000L0', 'Comparator': 'GreaterThanOrEqualTo', 'IntegerValues': [90], 'RequiredToPreview': True, }] qr.append({ 'QualificationTypeId': '00000000000000000071', 'Comparator': 'EqualTo', 'LocaleValues': [{ 'Country': 'US' }], 'RequiredToPreview': True }) ## Make up hit qualification qr.append({ 'QualificationTypeId': '39G8RJBXZVGXWGOFKKWZFWUS2DYSFD', 'Comparator': 'Exists', 'ActionsGuarded': 'PreviewAndAccept' }) ''' ## Selective worker qualification qr = [{ 'QualificationTypeId': '38TZ8V8N0DPKTFADTBYQNO29VLSIPN', 'Comparator': 'Exists', 'ActionsGuarded': 'PreviewAndAccept' }] ''' mtc = boto3.client('mturk', endpoint_url=HOST, region_name=region_name, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key) theHit = mtc.create_hit( Question=q.get_as_xml(), LifetimeInSeconds=lifetime, MaxAssignments=max_assignments, Title=title, Description=description, Keywords=keywords, Reward=pay, AssignmentDurationInSeconds=60 * 60, # 60 minutes AutoApprovalDelayInSeconds=2 * 24 * 60 * 60, # the number of seconds after an assignment is submitted is it automatically approved unless explicitly rejected ## the norm is to try to keep this under 7 days, many requesters approve in less than 3 days RequesterAnnotation=description, QualificationRequirements=qr) print theHit['HIT']['HITId'] return theHit['HIT']['HITId']
from boto.mturk.question import ExternalQuestion import configurations region_name = 'us-east-1' mturk = boto3.client( 'mturk', endpoint_url='https://mturk-requester.us-east-1.amazonaws.com', region_name='us-east-1', aws_access_key_id=configurations.aws_access_key_id, aws_secret_access_key=configurations.aws_secret_access_key, ) balance = mturk.get_account_balance() print("Available balance: " + balance["AvailableBalance"]) question = ExternalQuestion(configurations.api_url, frame_height=0) new_hit = mturk.create_hit( Title='Image Sequences Ordering', Description='Order image sequences to tell a story.', Keywords='question, answer, research, images, sequences', Reward='0.12', MaxAssignments=70, LifetimeInSeconds=4320000, AssignmentDurationInSeconds=600, AutoApprovalDelayInSeconds=604800, Question=question.get_as_xml() ) print("HITID = " + new_hit['HIT']['HITId'])