Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

EMRJobRunner._aws_region is '' instead of None

  • Loading branch information...
commit c41e451fcf9e12b1af6c0dd9b4bcfba15a640146 1 parent 62197d8
David Marin authored
Showing with 24 additions and 5 deletions.
  1. +4 −4 mrjob/emr.py
  2. +19 −0 tests/emr_test.py
  3. +1 −1  tests/mockboto.py
8 mrjob/emr.py
View
@@ -81,7 +81,7 @@
'EU': 'eu-west-1.elasticmapreduce.amazonaws.com',
'us-east-1': 'us-east-1.elasticmapreduce.amazonaws.com',
'us-west-1': 'us-west-1.elasticmapreduce.amazonaws.com',
- None: 'elasticmapreduce.amazonaws.com', # when no region specified
+ '': 'elasticmapreduce.amazonaws.com', # when no region specified
}
# map from AWS region to S3 endpoint
@@ -91,7 +91,7 @@
'us-east-1': 's3.amazonaws.com', # no region-specific endpoint
'us-west-1': 's3-us-west-1.amazonaws.com',
'ap-southeast-1': 's3-ap-southeast-1.amazonaws.com', # no EMR endpoint yet
- None: 's3.amazonaws.com',
+ '': 's3.amazonaws.com',
}
def parse_s3_uri(uri):
@@ -270,7 +270,7 @@ def __init__(self, **kwargs):
# make aws_region an instance variable; we might want to set it
# based on the scratch bucket
- self._aws_region = self._opts['aws_region']
+ self._aws_region = self._opts['aws_region'] or ''
# if we're going to create a bucket to use as temp space, we don't
# want to actually create it until we run the job (Issue #50).
@@ -397,7 +397,7 @@ def _fix_s3_scratch_and_log_uri_opts(self):
# if we're not using an ancient version of boto, set region
# based on the bucket's region
if (hasattr(scratch_bucket, 'get_location')):
- self._aws_region = scratch_bucket.get_location()
+ self._aws_region = scratch_bucket.get_location() or ''
if self._aws_region:
log.info("using scratch bucket's region (%s) to connect to AWS" %
self._aws_region)
19 tests/emr_test.py
View
@@ -490,6 +490,25 @@ def test_no_region(self):
'elasticmapreduce.amazonaws.com')
assert_equal(runner.make_s3_conn().endpoint,
's3.amazonaws.com')
+ assert_equal(runner._aws_region, '')
+
+ def test_none_region(self):
+ # blank region should be treated the same as no region
+ runner = EMRJobRunner(conf_path=False, aws_region=None)
+ assert_equal(runner.make_emr_conn().endpoint,
+ 'elasticmapreduce.amazonaws.com')
+ assert_equal(runner.make_s3_conn().endpoint,
+ 's3.amazonaws.com')
+ assert_equal(runner._aws_region, '')
+
+ def test_blank_region(self):
+ # blank region should be treated the same as no region
+ runner = EMRJobRunner(conf_path=False, aws_region='')
+ assert_equal(runner.make_emr_conn().endpoint,
+ 'elasticmapreduce.amazonaws.com')
+ assert_equal(runner.make_s3_conn().endpoint,
+ 's3.amazonaws.com')
+ assert_equal(runner._aws_region, '')
def test_eu(self):
runner = EMRJobRunner(conf_path=False, aws_region='EU')
2  tests/mockboto.py
View
@@ -64,7 +64,7 @@ def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
from bucket name to key name to bytes.
"""
self.mock_s3_fs = mock_s3_fs or {}
- self.endpoint = host
+ self.endpoint = host or 's3.amazonaws.com'
def get_bucket(self, bucket_name):
if bucket_name in self.mock_s3_fs:
Please sign in to comment.
Something went wrong with that request. Please try again.