1 def done(self, record, tmpdir, outdir, keepdir):
2 colname = "Output %s of %s" % (record["output"][0:7], self.name)
4 # check if collection already exists with same owner, name and content
5 collection_exists = self.arvrunner.api.collections().list(
6 filters=[["owner_uuid", "=", self.arvrunner.project_uuid],
7 ['portable_data_hash', '=', record["output"]],
8 ["name", "=", colname]]
9 ).execute(num_retries=self.arvrunner.num_retries)
11 if not collection_exists["items"]:
12 # Create a collection located in the same project as the
13 # pipeline with the contents of the output.
14 # First, get output record.
15 collections = self.arvrunner.api.collections().list(
17 filters=[['portable_data_hash', '=', record["output"]]],
18 select=["manifest_text"]
19 ).execute(num_retries=self.arvrunner.num_retries)
21 if not collections["items"]:
22 raise WorkflowException(
23 "Job output '%s' cannot be found on API server" % (
26 # Create new collection in the parent project
27 # with the output contents.
28 self.arvrunner.api.collections().create(body={
29 "owner_uuid": self.arvrunner.project_uuid,
31 "portable_data_hash": record["output"],
32 "manifest_text": collections["items"][0]["manifest_text"]
33 }, ensure_unique_name=True).execute(
34 num_retries=self.arvrunner.num_retries)
36 self.builder.outdir = outdir
37 self.builder.pathmapper.keepdir = keepdir
38 return self.collect_outputs("keep:" + record["output"])