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")
16 for c in contents["items"]:
17 if c["kind"] == "arvados#workflow" and c["uuid"] == wf_uuid:
20 raise Exception("Couldn't find workflow")
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 wf_uuid = subprocess.check_output(["arvados-cwl-runner", "--create-workflow", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"])
46 wf_uuid = wf_uuid.decode("utf-8").strip()
47 check_contents(group, wf_uuid)
49 api.groups().delete(uuid=group["uuid"]).execute()
53 group = api.groups().create(body={"group": {"name": "test-19070-project-2", "group_class": "project"}}, ensure_unique_name=True).execute()
55 contents = api.groups().contents(uuid=group["uuid"]).execute()
56 if len(contents["items"]) != 0:
57 raise Exception("Expected 0 items")
59 # Create workflow, but with --no-copy-deps it shouldn't copy anything
60 wf_uuid = subprocess.check_output(["arvados-cwl-runner", "--no-copy-deps", "--create-workflow", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"])
61 wf_uuid = wf_uuid.decode("utf-8").strip()
63 contents = api.groups().contents(uuid=group["uuid"]).execute()
64 if len(contents["items"]) != 1:
65 raise Exception("Expected 1 items")
68 for c in contents["items"]:
69 if c["kind"] == "arvados#workflow" and c["uuid"] == wf_uuid:
72 raise Exception("Couldn't find workflow")
74 # Updating by default will copy missing items
75 wf_uuid = subprocess.check_output(["arvados-cwl-runner", "--update-workflow", wf_uuid, "19070-copy-deps.cwl"])
76 wf_uuid = wf_uuid.decode("utf-8").strip()
77 check_contents(group, wf_uuid)
80 api.groups().delete(uuid=group["uuid"]).execute()
84 group = api.groups().create(body={"group": {"name": "test-19070-project-3", "group_class": "project"}}, ensure_unique_name=True).execute()
86 contents = api.groups().contents(uuid=group["uuid"]).execute()
87 if len(contents["items"]) != 0:
88 raise Exception("Expected 0 items")
90 # Execute workflow, shouldn't copy anything.
91 wf_uuid = subprocess.check_output(["arvados-cwl-runner", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"])
92 wf_uuid = wf_uuid.decode("utf-8").strip()
94 contents = api.groups().contents(uuid=group["uuid"]).execute()
96 # final output collection
98 # step output collection
99 # container request log
100 if len(contents["items"]) != 5:
101 raise Exception("Expected 5 items")
104 for c in contents["items"]:
105 if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "d7514270f356df848477718d58308cc4+94":
108 raise Exception("Didn't expect to find collection dependency")
111 for c in contents["items"]:
112 if c["kind"] == "arvados#collection" and c["name"].startswith("Docker image arvados jobs"):
115 raise Exception("Didn't expect to find jobs image dependency")
117 # Execute workflow with --copy-deps
118 wf_uuid = subprocess.check_output(["arvados-cwl-runner", "--project-uuid", group["uuid"], "--copy-deps", "19070-copy-deps.cwl"])
119 wf_uuid = wf_uuid.decode("utf-8").strip()
121 contents = api.groups().contents(uuid=group["uuid"]).execute()
123 for c in contents["items"]:
124 if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "d7514270f356df848477718d58308cc4+94":
127 raise Exception("Couldn't find collection dependency")
130 for c in contents["items"]:
131 if c["kind"] == "arvados#collection" and c["name"].startswith("Docker image arvados jobs"):
134 raise Exception("Couldn't find jobs image dependency")
137 api.groups().delete(uuid=group["uuid"]).execute()
139 if __name__ == '__main__':