[ARVADOS] updated: f70584ec2cd2782528ec492a49bf852a8db23bfc
git at public.curoverse.com
git at public.curoverse.com
Mon Feb 23 13:53:30 EST 2015
Summary of changes:
sdk/python/arvados/commands/arv_copy.py | 83 ++++++++++++++++-----------------
sdk/python/arvados/keep.py | 4 ++
2 files changed, 45 insertions(+), 42 deletions(-)
via f70584ec2cd2782528ec492a49bf852a8db23bfc (commit)
via b7642ef621f0a77ea87f212aabb46554e5010b17 (commit)
from 74784b33fd7b8b519b0ce0cbbdfa16dba2dad219 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit f70584ec2cd2782528ec492a49bf852a8db23bfc
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Mon Feb 23 13:55:41 2015 -0500
4520: Bonus fix because arv-copy was giving KeepClient.put() unicode strings
instead of byte strings. KeepClient will now reject that.
diff --git a/sdk/python/arvados/keep.py b/sdk/python/arvados/keep.py
index 262e688..1b72687 100644
--- a/sdk/python/arvados/keep.py
+++ b/sdk/python/arvados/keep.py
@@ -684,6 +684,10 @@ class KeepClient(object):
exponential backoff. The default value is set when the
KeepClient is initialized.
"""
+
+ if type(data) is not str:
+ raise arvados.errors.ArgumentError("Argument 'data' to KeepClient.put must be type 'str'")
+
data_hash = hashlib.md5(data).hexdigest()
if copies < 1:
return data_hash
commit b7642ef621f0a77ea87f212aabb46554e5010b17
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Mon Feb 23 13:54:47 2015 -0500
4520: Refactor code to create the collection record. Also refactored code
which creates Docker metadata links so that copying any collection which
represents a Docker image will also copy over the metadata.
diff --git a/sdk/python/arvados/commands/arv_copy.py b/sdk/python/arvados/commands/arv_copy.py
index 57f79b8..18c4396 100755
--- a/sdk/python/arvados/commands/arv_copy.py
+++ b/sdk/python/arvados/commands/arv_copy.py
@@ -375,6 +375,43 @@ def total_collection_size(manifest_text):
return total_bytes
+def create_collection_from(c, src, dst, args):
+ """Create a new collection record on dst, and copy Docker metadata if
+ available."""
+
+ collection_uuid = c['uuid']
+
+ del c['uuid']
+
+ if 'properties' in c:
+ del c['properties']
+
+ if args.project_uuid:
+ c['owner_uuid'] = args.project_uuid
+ elif 'owner_uuid' in c:
+ del c['owner_uuid']
+
+ dst_collection = dst.collections().create(body=c, ensure_unique_name=True).execute(num_retries=args.retries)
+
+ # Create docker_image_repo+tag and docker_image_hash links
+ # at the destination.
+ for link_class in ("docker_image_repo+tag", "docker_image_hash"):
+ docker_links = src.links().list(filters=[["head_uuid", "=", collection_uuid], ["link_class", "=", link_class]]).execute(num_retries=args.retries)['items']
+
+ for d in docker_links:
+ body={
+ 'head_uuid': dst_collection['uuid'],
+ 'link_class': link_class,
+ 'name': d['name'],
+ }
+ if args.project_uuid:
+ body['owner_uuid'] = args.project_uuid
+
+ lk = dst.links().create(body=body).execute(num_retries=args.retries)
+ logger.debug('created dst link {}'.format(lk))
+
+ return dst_collection
+
# copy_collection(obj_uuid, src, dst, args)
#
# Copies the collection identified by obj_uuid from src to dst.
@@ -413,13 +450,9 @@ def copy_collection(obj_uuid, src, dst, args):
).execute()
if dstcol['items_available'] > 0:
if args.project_uuid:
- c['owner_uuid'] = args.project_uuid
- del c['uuid']
- if 'properties' in c:
- del c['properties']
- return dst.collections().create(body=c, ensure_unique_name=True).execute()
+ return create_collection_from(c, src, dst, args)
else:
- logger.info("Skipping collection %s (already at dst)", obj_uuid)
+ logger.debug("Skipping collection %s (already at dst)", obj_uuid)
return dstcol['items'][0]
# Fetch the collection's manifest.
@@ -472,20 +505,10 @@ def copy_collection(obj_uuid, src, dst, args):
# Copy the manifest and save the collection.
logger.debug('saving %s with manifest: <%s>', obj_uuid, dst_manifest)
- dst_keep.put(dst_manifest)
-
- del c['uuid']
- if 'properties' in c:
- del c['properties']
-
- if args.project_uuid:
- c['owner_uuid'] = args.project_uuid
- elif 'owner_uuid' in c:
- del c['owner_uuid']
+ dst_keep.put(dst_manifest.encode('utf-8'))
c['manifest_text'] = dst_manifest
-
- return dst.collections().create(body=c, ensure_unique_name=True).execute()
+ return create_collection_from(c, src, dst, args)
# copy_git_repo(src_git_repo, src, dst, dst_git_repo, script_version)
#
@@ -582,30 +605,6 @@ def copy_docker_image(docker_image, docker_image_tag, src, dst, args):
# Copy the collection it refers to.
dst_image_col = copy_collection(image_uuid, src, dst, args)
- # Create docker_image_repo+tag and docker_image_hash links
- # at the destination.
- body={
- 'head_uuid': dst_image_col['uuid'],
- 'link_class': 'docker_image_repo+tag',
- 'name': "{}:{}".format(docker_image, docker_image_tag),
- }
- if args.project_uuid:
- body['owner_uuid'] = args.project_uuid
-
- lk = dst.links().create(body=body).execute(num_retries=args.retries)
- logger.debug('created dst link {}'.format(lk))
-
- body={
- 'head_uuid': dst_image_col['uuid'],
- 'link_class': 'docker_image_hash',
- 'name': dst_image_col['portable_data_hash'],
- }
- if args.project_uuid:
- body['owner_uuid'] = args.project_uuid
-
- lk = dst.links().create(body=body).execute(num_retries=args.retries)
- logger.debug('created dst link {}'.format(lk))
-
# git_rev_parse(rev, repo)
#
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list