Skip to content

Commit

Permalink
Merge pull request #43 from 4dn-dcic/s3zip
Browse files Browse the repository at this point in the history
s3_util unzip function can take file suffices instead of full file name
  • Loading branch information
carlvitzthum authored Aug 7, 2019
2 parents 554347a + 90be818 commit dff7023
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 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.7.5"
__version__ = "0.7.6"
10 changes: 3 additions & 7 deletions dcicutils/s3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,7 @@ def read_s3_zipfile(self, s3key, files_to_extract):
ret_files[name] = zipstream.open(zipped_filename).read()
return ret_files

def unzip_s3_to_s3(self, zipped_s3key, dest_dir, retfile_names=None, acl=None):
if retfile_names is None:
retfile_names = []

def unzip_s3_to_s3(self, zipped_s3key, dest_dir, acl=None):
if not dest_dir.endswith('/'):
dest_dir += '/'

Expand All @@ -218,9 +215,8 @@ def unzip_s3_to_s3(self, zipped_s3key, dest_dir, retfile_names=None, acl=None):
# files twice that we want to further interogate
the_file = zipstream.open(file_name, 'r').read()
file_to_find = file_name.split('/')[-1]
if file_to_find in retfile_names:
ret_files[file_to_find] = {'s3key': s3_key,
'data': the_file}
ret_files[file_to_find] = {'s3key': s3_key,
'data': the_file}
self.s3_put(the_file, s3_file_name, acl=acl)

return ret_files
Expand Down
4 changes: 1 addition & 3 deletions test/test_s3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ def test_unzip_s3_to_s3(integrated_s3_info):
assert [] == objs.get('Contents', [])

# now copy to that dir we just deleted
retfile_list = ['summary.txt', 'fastqc_data.txt', 'fastqc_report.html']
ret_files = integrated_s3_info['s3Obj'].unzip_s3_to_s3(filename, prefix, retfile_list)
assert 3 == len(ret_files.keys())
ret_files = integrated_s3_info['s3Obj'].unzip_s3_to_s3(filename, prefix)
assert ret_files['fastqc_report.html']['s3key'].startswith("https://s3.amazonaws.com")

objs = integrated_s3_info['s3Obj'].s3_read_dir(prefix)
Expand Down

0 comments on commit dff7023

Please sign in to comment.