Skip to content

Commit

Permalink
Merge pull request #18 from 4dn-dcic/0.3.2
Browse files Browse the repository at this point in the history
0.3.2
  • Loading branch information
Carl Vitzthum authored Jul 12, 2018
2 parents ae1d383 + 340c445 commit 34991e5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion dcicutils/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Version information."""

# The following line *must* be the last in the module, exactly as formatted:
__version__ = "0.3.1"
__version__ = "0.3.2"
42 changes: 24 additions & 18 deletions dcicutils/es_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,41 @@
'''


def get_index_list(client, name, days_old=0, timestring='%Y.%m.%d', ilo=None):
if ilo is None:
ilo = curator.IndexList(client)

ilo.filter_by_regex(kind='prefix', value=name)
ilo.filter_by_age(source='name', direction='older', timestring=timestring, unit='days',
unit_count=days_old)
return ilo


def create_es_client(es_url, use_aws_auth=False):
def create_es_client(es_url, use_aws_auth=True, **options):
"""
Use to create a ES that supports the signature version 4 signing process.
Need to do role-based IAM access control for AWS hosted ES.
Takes a string es server url, boolean whether or not to use aws auth
signing procedure, and any additional kwargs that will be passed to
creation of the Elasticsearch client.
"""
# may be passed in as a list, as was done previously
if isinstance(es_url, (list, tuple)):
addresses = es_url
else:
addresses = [es_url, ]
es_url = es_url[0]

es_options = {'retry_on_timeout': True,
'maxsize': 50 # parallellism...
}
'maxsize': 50} # parallellism...
if use_aws_auth:
host = addresses[0].split('//')
host = es_url.split('//') # remove schema from url
host = host[-1].split(":")
auth = BotoAWSRequestsAuth(aws_host=host[0].rstrip('/'),
aws_region='us-east-1',
aws_service='es')
es_options['connection_class'] = RequestsHttpConnection
es_options['http_auth'] = auth
es_options.update(**options) # add any given keyword options at the end

return Elasticsearch(addresses, **es_options)
return Elasticsearch(es_url, **es_options)


def get_index_list(client, name, days_old=0, timestring='%Y.%m.%d', ilo=None):
if ilo is None:
ilo = curator.IndexList(client)

ilo.filter_by_regex(kind='prefix', value=name)
ilo.filter_by_age(source='name', direction='older', timestring=timestring, unit='days',
unit_count=days_old)
return ilo


def create_snapshot_repo(client, repo_name, s3_bucket):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
packages=['dcicutils'],
include_package_data=True,
zip_safe=False,
author='$dn Team at Harvard Medical School',
author_email='jeremy_johnson@hms.harvard.edu',
author='4DN Team at Harvard Medical School',
author_email='burak_alver@hms.harvard.edu',
url='https://data.4dnucleome.org',
license='MIT',
install_requires=requires,
Expand Down

0 comments on commit 34991e5

Please sign in to comment.