1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
6 import arvados.collection
11 workflow_content = """# Copyright (C) The Arvados Authors. All rights reserved.
13 # SPDX-License-Identifier: Apache-2.0
16 class: CommandLineTool
25 location: keep:d7514270f356df848477718d58308cc4+94/b
30 expect_file = "19070-copy-deps.cwl"
32 def check_workflow_content(uuid):
33 c = arvados.collection.Collection(uuid)
35 with c.open(expect_file) as f:
37 match = (content == workflow_content)
42 def check_contents(group, wf_uuid):
43 contents = api.groups().contents(uuid=group["uuid"]).execute()
44 if len(contents["items"]) != 4:
45 raise Exception("Expected 4 items in "+group["uuid"]+" was "+str(len(contents["items"])))
48 for c in contents["items"]:
49 if c["kind"] == "arvados#workflow" and c["uuid"] == wf_uuid:
52 raise Exception("Couldn't find workflow in "+group["uuid"])
55 for c in contents["items"]:
56 if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "d7514270f356df848477718d58308cc4+94":
59 raise Exception("Couldn't find collection dependency")
62 for c in contents["items"]:
63 if c["kind"] == "arvados#collection" and c["name"].startswith("Docker image arvados jobs"):
66 raise Exception("Couldn't find jobs image dependency")
69 for c in contents["items"]:
70 if c["kind"] == "arvados#collection" and check_workflow_content(c["portable_data_hash"]):
73 raise Exception("Couldn't find collection containing expected "+expect_file)
77 group = api.groups().create(body={"group": {"name": "test-19070-project-1", "group_class": "project"}}, ensure_unique_name=True).execute()
79 contents = api.groups().contents(uuid=group["uuid"]).execute()
80 if len(contents["items"]) != 0:
81 raise Exception("Expected 0 items")
83 # Create workflow, by default should also copy dependencies
84 cmd = ["arvados-cwl-runner", "--disable-git", "--create-workflow", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"]
86 wf_uuid = subprocess.check_output(cmd)
87 wf_uuid = wf_uuid.decode("utf-8").strip()
88 check_contents(group, wf_uuid)
90 api.groups().delete(uuid=group["uuid"]).execute()
94 group = api.groups().create(body={"group": {"name": "test-19070-project-2", "group_class": "project"}}, ensure_unique_name=True).execute()
96 contents = api.groups().contents(uuid=group["uuid"]).execute()
97 if len(contents["items"]) != 0:
98 raise Exception("Expected 0 items")
100 # Create workflow, but with --no-copy-deps it shouldn't copy anything
101 cmd = ["arvados-cwl-runner", "--disable-git", "--no-copy-deps", "--create-workflow", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"]
103 wf_uuid = subprocess.check_output(cmd)
104 wf_uuid = wf_uuid.decode("utf-8").strip()
106 contents = api.groups().contents(uuid=group["uuid"]).execute()
107 if len(contents["items"]) != 2:
108 raise Exception("Expected 2 items")
111 for c in contents["items"]:
112 if c["kind"] == "arvados#workflow" and c["uuid"] == wf_uuid:
115 raise Exception("Couldn't find workflow")
118 for c in contents["items"]:
119 if c["kind"] == "arvados#collection" and check_workflow_content(c["portable_data_hash"]):
122 raise Exception("Couldn't find collection containing expected "+expect_file)
124 # Updating by default will copy missing items
125 cmd = ["arvados-cwl-runner", "--disable-git", "--update-workflow", wf_uuid, "19070-copy-deps.cwl"]
127 wf_uuid = subprocess.check_output(cmd)
128 wf_uuid = wf_uuid.decode("utf-8").strip()
129 check_contents(group, wf_uuid)
132 api.groups().delete(uuid=group["uuid"]).execute()
136 group = api.groups().create(body={"group": {"name": "test-19070-project-3", "group_class": "project"}}, ensure_unique_name=True).execute()
138 contents = api.groups().contents(uuid=group["uuid"]).execute()
139 if len(contents["items"]) != 0:
140 raise Exception("Expected 0 items")
142 # Execute workflow, shouldn't copy anything.
143 cmd = ["arvados-cwl-runner", "--disable-git", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"]
145 wf_uuid = subprocess.check_output(cmd)
146 wf_uuid = wf_uuid.decode("utf-8").strip()
148 contents = api.groups().contents(uuid=group["uuid"]).execute()
150 # final output collection
152 # step output collection
153 # container request log
154 if len(contents["items"]) != 5:
155 raise Exception("Expected 5 items")
158 for c in contents["items"]:
159 if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "d7514270f356df848477718d58308cc4+94":
162 raise Exception("Didn't expect to find collection dependency")
165 for c in contents["items"]:
166 if c["kind"] == "arvados#collection" and c["name"].startswith("Docker image arvados jobs"):
169 raise Exception("Didn't expect to find jobs image dependency")
171 # Execute workflow with --copy-deps
172 cmd = ["arvados-cwl-runner", "--disable-git", "--project-uuid", group["uuid"], "--copy-deps", "19070-copy-deps.cwl"]
174 wf_uuid = subprocess.check_output(cmd)
175 wf_uuid = wf_uuid.decode("utf-8").strip()
177 contents = api.groups().contents(uuid=group["uuid"]).execute()
179 for c in contents["items"]:
180 if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "d7514270f356df848477718d58308cc4+94":
183 raise Exception("Couldn't find collection dependency")
186 for c in contents["items"]:
187 if c["kind"] == "arvados#collection" and c["name"].startswith("Docker image arvados jobs"):
190 raise Exception("Couldn't find jobs image dependency")
193 api.groups().delete(uuid=group["uuid"]).execute()
195 if __name__ == '__main__':