You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0 KiB

import exhausting_mturk.api
import argparse
import logging
import coloredlogs
if __name__ == "__main__":
argParser = argparse.ArgumentParser(
description='Make and request hits')
argParser.add_argument(
'--batchdir',
'-d',
type=str,
default="batches",
help='directory to read and write from'
)
argParser.add_argument(
'--config',
'-c',
required=True,
type=str,
help='The yaml config file to load'
)
argParser.add_argument(
'--verbose',
'-v',
action='store_true',
help='Increase log level'
)
argParser.add_argument(
'--publish',
'-p',
type=str,
help='Publish a batch to MTurk'
)
argParser.add_argument(
'--update',
'-u',
action='store_true',
help='fetch HIT status and assignments from MTurk'
)
argParser.add_argument(
'--for-real',
action='store_true',
help='run on live MTurk instead of sandbox'
)
args = argParser.parse_args()
loglevel = logging.DEBUG if args.verbose else logging.INFO
coloredlogs.install(
level=loglevel,
fmt="%(asctime)s %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s"
)
logger = logging.getLogger("exhausting_mturk")
logging.getLogger('botocore').setLevel(logging.INFO)
connection = exhausting_mturk.api.Connection(args.config, args.for_real)
print(f"{connection}")
batch_files = exhausting_mturk.api.get_batch_files(args.batchdir)
logger.info(f"{batch_files=}")
# print(exhausting_mturk.api.batch_to_xml(batches[0]))
if args.update:
connection.load_new_submissions()
elif args.publish:
if args.publish not in batch_files:
raise Exception(f'Not a valid batch. Use one of {batches=}')
batch = exhausting_mturk.api.open_batch(args.publish)
connection.publish_hit(batch)
# connection.load_new_submissions()