1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
10 def check_contents(group, wf_uuid):
11 contents = api.groups().contents(uuid=group["uuid"]).execute()
12 if len(contents["items"]) != 3:
13 raise Exception("Expected 3 items in "+group["uuid"]+" was "+len(contents["items"]))
16 for c in contents["items"]:
17 if c["kind"] == "arvados#workflow" and c["uuid"] == wf_uuid:
20 raise Exception("Couldn't find workflow in "+group["uuid"])
23 for c in contents["items"]:
24 if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "d7514270f356df848477718d58308cc4+94":
27 raise Exception("Couldn't find collection dependency")
30 for c in contents["items"]:
31 if c["kind"] == "arvados#collection" and c["name"].startswith("Docker image arvados jobs"):
34 raise Exception("Couldn't find jobs image dependency")
38 group = api.groups().create(body={"group": {"name": "test-19070-project-1", "group_class": "project"}}, ensure_unique_name=True).execute()
40 contents = api.groups().contents(uuid=group["uuid"]).execute()
41 if len(contents["items"]) != 0:
42 raise Exception("Expected 0 items")
44 # Create workflow, by default should also copy dependencies
45 cmd = ["arvados-cwl-runner", "--create-workflow", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"]
47 wf_uuid = subprocess.check_output(cmd)
48 wf_uuid = wf_uuid.decode("utf-8").strip()
49 check_contents(group, wf_uuid)
51 api.groups().delete(uuid=group["uuid"]).execute()
55 group = api.groups().create(body={"group": {"name": "test-19070-project-2", "group_class": "project"}}, ensure_unique_name=True).execute()
57 contents = api.groups().contents(uuid=group["uuid"]).execute()
58 if len(contents["items"]) != 0:
59 raise Exception("Expected 0 items")
61 # Create workflow, but with --no-copy-deps it shouldn't copy anything
62 cmd = ["arvados-cwl-runner", "--no-copy-deps", "--create-workflow", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"]
64 wf_uuid = subprocess.check_output(cmd)
65 wf_uuid = wf_uuid.decode("utf-8").strip()
67 contents = api.groups().contents(uuid=group["uuid"]).execute()
68 if len(contents["items"]) != 1:
69 raise Exception("Expected 1 items")
72 for c in contents["items"]:
73 if c["kind"] == "arvados#workflow" and c["uuid"] == wf_uuid:
76 raise Exception("Couldn't find workflow")
78 # Updating by default will copy missing items
79 cmd = ["arvados-cwl-runner", "--update-workflow", wf_uuid, "19070-copy-deps.cwl"]
81 wf_uuid = subprocess.check_output(cmd)
82 wf_uuid = wf_uuid.decode("utf-8").strip()
83 check_contents(group, wf_uuid)
86 api.groups().delete(uuid=group["uuid"]).execute()
90 group = api.groups().create(body={"group": {"name": "test-19070-project-3", "group_class": "project"}}, ensure_unique_name=True).execute()
92 contents = api.groups().contents(uuid=group["uuid"]).execute()
93 if len(contents["items"]) != 0:
94 raise Exception("Expected 0 items")
96 # Execute workflow, shouldn't copy anything.
97 cmd = ["arvados-cwl-runner", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"]
99 wf_uuid = subprocess.check_output(cmd)
100 wf_uuid = wf_uuid.decode("utf-8").strip()
102 contents = api.groups().contents(uuid=group["uuid"]).execute()
104 # final output collection
106 # step output collection
107 # container request log
108 if len(contents["items"]) != 5:
109 raise Exception("Expected 5 items")
112 for c in contents["items"]:
113 if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "d7514270f356df848477718d58308cc4+94":
116 raise Exception("Didn't expect to find collection dependency")
119 for c in contents["items"]:
120 if c["kind"] == "arvados#collection" and c["name"].startswith("Docker image arvados jobs"):
123 raise Exception("Didn't expect to find jobs image dependency")
125 # Execute workflow with --copy-deps
126 cmd = ["arvados-cwl-runner", "--project-uuid", group["uuid"], "--copy-deps", "19070-copy-deps.cwl"]
128 wf_uuid = subprocess.check_output(cmd)
129 wf_uuid = wf_uuid.decode("utf-8").strip()
131 contents = api.groups().contents(uuid=group["uuid"]).execute()
133 for c in contents["items"]:
134 if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "d7514270f356df848477718d58308cc4+94":
137 raise Exception("Couldn't find collection dependency")
140 for c in contents["items"]:
141 if c["kind"] == "arvados#collection" and c["name"].startswith("Docker image arvados jobs"):
144 raise Exception("Couldn't find jobs image dependency")
147 api.groups().delete(uuid=group["uuid"]).execute()
149 if __name__ == '__main__':