File size: 1,699 Bytes
d5b2eed
 
 
 
d876d62
d5b2eed
 
 
 
 
 
 
 
 
 
 
 
 
 
305a351
d876d62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d5b2eed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Basic example for running MTurk data collection against a Space
# For more information see https://docs.aws.amazon.com/mturk/index.html

import boto3
from boto.mturk.question import HTMLQuestion

from config import MTURK_KEY, MTURK_SECRET

MTURK_REGION = "us-east-1"
MTURK_SANDBOX = "https://mturk-requester-sandbox.us-east-1.amazonaws.com"

mturk = boto3.client(
    "mturk",
    aws_access_key_id=MTURK_KEY,
    aws_secret_access_key=MTURK_SECRET,
    region_name=MTURK_REGION,
    endpoint_url=MTURK_SANDBOX,
)

# The + in the URL makes the Space easily embeddable in an iframe
question = HTMLQuestion(
    """
    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="utf-8" />
    		<meta name="viewport" content="width=device-width" />
    		<title>My static Space</title>
    		<link rel="shortcut icon" href="#" type="image/x-icon">
    		<link rel="stylesheet" href="style.css" />
    		<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
    		<script type="module" crossorigin src="https://gradio.s3-us-west-2.amazonaws.com/3.0.17/gradio.js"></script>
    	</head>
    	<body>
    		<gradio-app space="Tristan/dadc"></gradio-app>

    	</body>
    </html>
    """,
    frame_height=600
)

new_hit = mturk.create_hit(
    Title="DADC with Gradio",
    Description="Hello world",
    Keywords="fool the model",
    Reward="0.15",
    MaxAssignments=1,
    LifetimeInSeconds=172800,
    AssignmentDurationInSeconds=600,
    AutoApprovalDelayInSeconds=14400,
    Question=question.get_as_xml(),
)

print(
    "Sandbox link: https://workersandbox.mturk.com/mturk/preview?groupId="
    + new_hit["HIT"]["HITGroupId"]
)