Skip to content

Commit

Permalink
Merge branch 'master' into add-worker-management
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-dalton authored May 1, 2019
2 parents d71c86c + 151801f commit 1419ff7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
11 changes: 10 additions & 1 deletion amti/utils/mturk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Utilities for interacting with MTurk."""

import logging
import os
import boto3

from typing import Optional
Expand Down Expand Up @@ -29,10 +30,18 @@ def get_mturk_client(env):
region_name = settings.ENVS[env]['region_name']
endpoint_url = settings.ENVS[env]['endpoint_url']

profile = os.getenv('AWS_PROFILE')
if profile is None:
logger.debug('Creating mturk session with default environment/profile values.')
session = boto3.session.Session()
else:
logger.debug(f'Creating mturk session with profile_name {profile}')
session = boto3.session.Session(profile_name=profile)

logger.debug(
f'Creating mturk client in region {region_name} with endpoint'
f' {endpoint_url}.')
client = boto3.client(
client = session.client(
service_name='mturk',
region_name=region_name,
endpoint_url=endpoint_url)
Expand Down
18 changes: 11 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,17 @@ install the dependencies:
echo 'amti' > .python-version
pip install -r requirements.txt

Then, make sure that you have the proper environment variables set in
your `.envrc` file for this repo. In particular, you should have values
for:

AWS_ACCESS_KEY_ID
AWS_SECRET_KEY
AWS_SECRET_ACCESS_KEY
Then, make sure that you have the proper [AWS environment variables](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html) set in your `.envrc` file for this repo. In particular, you should have values
for either:
```
AWS_ACCESS_KEY_ID
AWS_SECRET_KEY
AWS_SECRET_ACCESS_KEY
```
or
```
AWS_PROFILE
```

That correspond to your Mechanical Turk account.

Expand Down

0 comments on commit 1419ff7

Please sign in to comment.