10349: Add code snippet for combining collections.
authorPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 12 Sep 2017 13:47:59 +0000 (09:47 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 12 Sep 2017 13:47:59 +0000 (09:47 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz@veritasgenetics.com>

doc/sdk/python/cookbook.html.textile.liquid

index 98a5fe848057af11f772d93296bd129553f49301..fa059f7028cd25db55e693d26439b5ce91697ecf 100644 (file)
@@ -134,3 +134,20 @@ token = api.api_client_authorizations().create(body={"api_client_authorization":
     "GET /arvados/v1/keep_services/accessible"]}}).execute()
 print("%s/c=%s/t=%s/_/" % (download, collection_uuid, token["api_token"]))
 </code></pre>
+
+h2. Combine two or more collections
+
+Note, if two collections have files of the same name, the contents will be concatenated in the resulting manifest.
+
+<pre><code>import arvados
+import arvados.collection
+api = arvados.api()
+project_uuid = "qr1hi-tpzed-zzzzzzzzzzzzzzz"
+collection_uuids = ["qr1hi-4zz18-aaaaaaaaaaaaaaa", "qr1hi-4zz18-bbbbbbbbbbbbbbb"]
+combined_manifest = ""
+for u in collection_uuids:
+    c = api.collections().get(uuid=u).execute()
+    combined_manifest += c["manifest_text"]
+newcol = arvados.collection.Collection(combined_manifest)
+newcol.save_new(name="My combined collection", owner_uuid=project_uuid)
+</code></pre>