Add "copy files from a collection to a new collection" to cookbook
authorPeter Amstutz <peter.amstutz@curii.com>
Fri, 17 Jan 2020 16:41:01 +0000 (11:41 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Fri, 17 Jan 2020 16:41:01 +0000 (11:41 -0500)
closes #16044

Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

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

index 0bc697077cf892aaad54c78c7c966316aa1c3f24..34f0a5014a58174b499b7d47ba089231efe2a9e0 100644 (file)
@@ -235,3 +235,24 @@ with c.open(filename, "rb") as reader:
             content = reader.read(128*1024)
 print("Finished downloading %s" % filename)
 {% endcodeblock %}
+
+h2. Copy files from a collection a new collection
+
+{% codeblock as python %}
+import arvados.collection
+
+source_collection = "x1u39-4zz18-krzg64ufvehgitl"
+target_project = "x1u39-j7d0g-67q94einb8ptznm"
+target_name = "Files copied from source_collection"
+files_to_copy = ["folder1/sample1/sample1_R1.fastq",
+                 "folder1/sample2/sample2_R1.fastq"]
+
+source = arvados.collection.CollectionReader(source_collection)
+target = arvados.collection.Collection()
+
+for f in files_to_copy:
+    target.copy(f, "", source_collection=source)
+
+target.save_new(name=target_name, owner_uuid=target_project)
+print("Created collection %s" % target.manifest_locator())
+{% endcodeblock %}