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"]) != 4:
13 raise Exception("Expected 4 items in "+group["uuid"]+" was "+str(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")
37 for c in contents["items"]:
38 if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "73b7a68c78205e793a5eb9520326d3ae+61":
41 raise Exception("Couldn't find collection containing workflow")
45 group = api.groups().create(body={"group": {"name": "test-19070-project-1", "group_class": "project"}}, ensure_unique_name=True).execute()
47 contents = api.groups().contents(uuid=group["uuid"]).execute()
48 if len(contents["items"]) != 0:
49 raise Exception("Expected 0 items")
51 # Create workflow, by default should also copy dependencies
52 cmd = ["arvados-cwl-runner", "--disable-git", "--create-workflow", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"]
54 wf_uuid = subprocess.check_output(cmd)
55 wf_uuid = wf_uuid.decode("utf-8").strip()
56 check_contents(group, wf_uuid)
58 api.groups().delete(uuid=group["uuid"]).execute()
62 group = api.groups().create(body={"group": {"name": "test-19070-project-2", "group_class": "project"}}, ensure_unique_name=True).execute()
64 contents = api.groups().contents(uuid=group["uuid"]).execute()
65 if len(contents["items"]) != 0:
66 raise Exception("Expected 0 items")
68 # Create workflow, but with --no-copy-deps it shouldn't copy anything
69 cmd = ["arvados-cwl-runner", "--disable-git", "--no-copy-deps", "--create-workflow", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"]
71 wf_uuid = subprocess.check_output(cmd)
72 wf_uuid = wf_uuid.decode("utf-8").strip()
74 contents = api.groups().contents(uuid=group["uuid"]).execute()
75 if len(contents["items"]) != 2:
76 raise Exception("Expected 2 items")
79 for c in contents["items"]:
80 if c["kind"] == "arvados#workflow" and c["uuid"] == wf_uuid:
83 raise Exception("Couldn't find workflow")
86 for c in contents["items"]:
87 if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "73b7a68c78205e793a5eb9520326d3ae+61":
90 raise Exception("Couldn't find collection containing workflow")
92 # Updating by default will copy missing items
93 cmd = ["arvados-cwl-runner", "--disable-git", "--update-workflow", wf_uuid, "19070-copy-deps.cwl"]
95 wf_uuid = subprocess.check_output(cmd)
96 wf_uuid = wf_uuid.decode("utf-8").strip()
97 check_contents(group, wf_uuid)
100 api.groups().delete(uuid=group["uuid"]).execute()
104 group = api.groups().create(body={"group": {"name": "test-19070-project-3", "group_class": "project"}}, ensure_unique_name=True).execute()
106 contents = api.groups().contents(uuid=group["uuid"]).execute()
107 if len(contents["items"]) != 0:
108 raise Exception("Expected 0 items")
110 # Execute workflow, shouldn't copy anything.
111 cmd = ["arvados-cwl-runner", "--disable-git", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"]
113 wf_uuid = subprocess.check_output(cmd)
114 wf_uuid = wf_uuid.decode("utf-8").strip()
116 contents = api.groups().contents(uuid=group["uuid"]).execute()
118 # final output collection
120 # step output collection
121 # container request log
122 if len(contents["items"]) != 5:
123 raise Exception("Expected 5 items")
126 for c in contents["items"]:
127 if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "d7514270f356df848477718d58308cc4+94":
130 raise Exception("Didn't expect to find collection dependency")
133 for c in contents["items"]:
134 if c["kind"] == "arvados#collection" and c["name"].startswith("Docker image arvados jobs"):
137 raise Exception("Didn't expect to find jobs image dependency")
139 # Execute workflow with --copy-deps
140 cmd = ["arvados-cwl-runner", "--disable-git", "--project-uuid", group["uuid"], "--copy-deps", "19070-copy-deps.cwl"]
142 wf_uuid = subprocess.check_output(cmd)
143 wf_uuid = wf_uuid.decode("utf-8").strip()
145 contents = api.groups().contents(uuid=group["uuid"]).execute()
147 for c in contents["items"]:
148 if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "d7514270f356df848477718d58308cc4+94":
151 raise Exception("Couldn't find collection dependency")
154 for c in contents["items"]:
155 if c["kind"] == "arvados#collection" and c["name"].startswith("Docker image arvados jobs"):
158 raise Exception("Couldn't find jobs image dependency")
161 api.groups().delete(uuid=group["uuid"]).execute()
163 if __name__ == '__main__':