Small improvements to scripts/grt/export.py for testing.

- Don't rely on external sha256sum, use Python hashing (add utility to hash_util to enable this).
- Drop unused galaxy_config from grt.yml.sample - it isn't used anywhere as far as I can tell.
This commit is contained in:
John Chilton
2018-03-23 16:14:49 -04:00
parent 198268a0aa
commit 8fa8660b25
3 changed files with 21 additions and 8 deletions
+19
View File
@@ -10,11 +10,30 @@ import logging
log = logging.getLogger(__name__)
BLOCK_SIZE = 1024 * 1024
sha1 = hashlib.sha1
sha256 = hashlib.sha256
sha = sha1
md5 = hashlib.md5
def memory_bound_hexdigest(hash_func, path=None, file=None):
hasher = hash_func()
if file is None:
assert path is not None
file = open(path, "rb")
else:
assert path is None, "Cannot specify path and path keyword arguments."
try:
for block in iter(lambda: file.read(BLOCK_SIZE), b''):
hasher.update(block)
return hasher.hexdigest()
finally:
file.close()
def md5_hash_file(path):
"""
Return a md5 hashdigest for a file or None if path could not be read.
+2 -4
View File
@@ -7,7 +7,6 @@ import argparse
import json
import logging
import os
import subprocess
import sys
import tarfile
import time
@@ -21,6 +20,7 @@ import galaxy
import galaxy.config
from galaxy.model import mapping
from galaxy.objectstore import build_object_store_from_config
from galaxy.util import hash_util
from galaxy.util.properties import load_app_properties
sample_config = os.path.abspath(os.path.join(os.path.dirname(__file__), 'grt.yml.sample'))
@@ -345,10 +345,8 @@ def main(argv):
os.unlink(REPORT_BASE + '.' + name + '.tsv')
_times.append(('job_finish', time.time() - _start_time))
sha = subprocess.check_output(['sha256sum', REPORT_BASE + '.tar.gz'])
sha = hash_util.memory_bound_hexdigest(hash_util.sha256, REPORT_BASE + ".tar.gz")
_times.append(('hash_finish', time.time() - _start_time))
# Strip out to space
sha = sha[0:sha.index(' ')]
# Now serialize the individual report data.
with open(REPORT_BASE + '.json', 'w') as handle:
-4
View File
@@ -1,7 +1,3 @@
# Location of your galaxy config file. The radio telescope will need to
# partially initialize a copy of galaxy.
galaxy_config: config/galaxy.ini
grt:
# Go to https://telescope.galaxyproject.org to obtain an Instance ID and API key
instance_id: