[ARVADOS] created: e507e67ee50852fc44011127eb42f535fe2ae493
Git user
git at public.curoverse.com
Fri Apr 14 16:06:58 EDT 2017
at e507e67ee50852fc44011127eb42f535fe2ae493 (commit)
commit e507e67ee50852fc44011127eb42f535fe2ae493
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Fri Apr 14 17:04:35 2017 -0300
11502: When getting a manifest using a PDH, the manifest is stripped.
Corrected test so that when comparing manifests, it does so by comparing stripped ones so that it doesn't intermittently fail.
diff --git a/sdk/python/arvados/commands/get.py b/sdk/python/arvados/commands/get.py
index f39e092..3c7954d 100755
--- a/sdk/python/arvados/commands/get.py
+++ b/sdk/python/arvados/commands/get.py
@@ -10,6 +10,7 @@ import logging
import arvados
import arvados.commands._util as arv_cmd
+import arvados.util as util
from arvados._version import __version__
@@ -131,17 +132,20 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
api_client = arvados.api('v1')
r = re.search(r'^(.*?)(/.*)?$', args.locator)
- collection = r.group(1)
+ col_loc = r.group(1)
get_prefix = r.group(2)
if args.r and not get_prefix:
get_prefix = os.sep
try:
- reader = arvados.CollectionReader(collection, num_retries=args.retries)
+ reader = arvados.CollectionReader(col_loc, num_retries=args.retries)
except Exception as error:
logger.error("failed to read collection: {}".format(error))
return 1
# User asked to download the collection's manifest
+ should_strip_manifest = False
+ if re.match(util.keep_locator_pattern, col_loc):
+ should_strip_manifest = True
if not get_prefix:
if not args.n:
open_flags = os.O_CREAT | os.O_WRONLY
@@ -149,16 +153,16 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
open_flags |= os.O_EXCL
try:
if args.destination == "-":
- stdout.write(reader.manifest_text())
+ stdout.write(reader.manifest_text(strip=should_strip_manifest))
else:
out_fd = os.open(args.destination, open_flags)
with os.fdopen(out_fd, 'wb') as out_file:
- out_file.write(reader.manifest_text())
+ out_file.write(reader.manifest_text(strip=should_strip_manifest))
except (IOError, OSError) as error:
logger.error("can't write to '{}': {}".format(args.destination, error))
return 1
except (arvados.errors.ApiError, arvados.errors.KeepReadError) as error:
- logger.error("failed to download '{}': {}".format(collection, error))
+ logger.error("failed to download '{}': {}".format(col_loc, error))
return 1
return 0
diff --git a/sdk/python/tests/test_arv_get.py b/sdk/python/tests/test_arv_get.py
index 907c671..1dbff37 100644
--- a/sdk/python/tests/test_arv_get.py
+++ b/sdk/python/tests/test_arv_get.py
@@ -26,6 +26,7 @@ class ArvadosGetTestCase(run_test_server.TestCaseWithServers):
shutil.rmtree(self.tempdir)
def write_test_collection(self,
+ strip_manifest=True,
contents = {
'foo.txt' : 'foo',
'bar.txt' : 'bar',
@@ -36,7 +37,9 @@ class ArvadosGetTestCase(run_test_server.TestCaseWithServers):
with c.open(path, 'w') as f:
f.write(data)
c.save_new()
- return (c.manifest_locator(), c.portable_data_hash(), c.manifest_text())
+ return (c.manifest_locator(),
+ c.portable_data_hash(),
+ c.manifest_text(strip=strip_manifest))
def run_get(self, args):
self.stdout = io.BytesIO()
@@ -75,9 +78,9 @@ class ArvadosGetTestCase(run_test_server.TestCaseWithServers):
def test_get_collection_manifest(self):
# Get the collection manifest
- r = self.run_get([self.col_loc, self.tempdir])
+ r = self.run_get([self.col_pdh, self.tempdir])
self.assertEqual(0, r)
- with open("{}/{}".format(self.tempdir, self.col_loc), "r") as f:
+ with open("{}/{}".format(self.tempdir, self.col_pdh), "r") as f:
self.assertEqual(self.col_manifest, f.read())
def test_invalid_collection(self):
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list