[ARVADOS] created: ed646f12b58e930fe018dc4caf2121294c26e375

Git user git at public.curoverse.com
Tue Mar 22 16:41:23 EDT 2016


        at  ed646f12b58e930fe018dc4caf2121294c26e375 (commit)


commit ed646f12b58e930fe018dc4caf2121294c26e375
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Mar 22 16:41:19 2016 -0400

    8766: Port logic from arv-run-pipeline-instance for copy collection to parent
    project.

diff --git a/sdk/cwl/arvados_cwl/__init__.py b/sdk/cwl/arvados_cwl/__init__.py
index bb884c5..f587ad1 100644
--- a/sdk/cwl/arvados_cwl/__init__.py
+++ b/sdk/cwl/arvados_cwl/__init__.py
@@ -232,6 +232,34 @@ class ArvadosJob(object):
                         #if tmpdir and outdir and keepdir:
                         #    break
 
+                        # Create a collection located in the same project as the pipeline with the contents of the output.
+                        # First, get output record.
+                        collections = self.arvrunner.api.collections().list(limit=1,
+                                                                           filters=[['portable_data_hash', '=', record["output"]]],
+                                                                           select=["portable_data_hash", "manifest_text"]
+                        ).execute(num_retries=self.arvrunner.num_retries)
+
+                        if collections["items"]:
+                            colname = "Output %s of %s" % (record["output"][0:7], self.name)
+
+                            # check if there is a name collision.
+                            name_collision = self.arvrunner.api.collections().list(filters=[["owner_uuid", "=", self.arvrunner.project_uuid],
+                                                                                            ["name", "=", name]]
+                            ).execute(num_retries=self.arvrunner.num_retries)
+
+                            if not name_collision["items"]:
+                                # Create new collection in the parent project
+                                # with the output contents.
+                                self.arvrunner.api.collections().create(body={
+                                    "owner_uuid": self.arvrunner.project_uuid,
+                                    "name": colname,
+                                    "portable_data_hash": collections[0]["portable_data_hash"],
+                                    "manifest_text": collections[0]["manifest_text"]
+                                }, ensure_unique_name=True).execute(num_retries=self.arvrunner.num_retries)
+
+                            # else: there is already a collection with the same name and the
+                            # same contents, so nothing to do.
+
                     self.builder.outdir = outdir
                     self.builder.pathmapper.keepdir = keepdir
                     outputs = self.collect_outputs("keep:" + record["output"])

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list