MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / test_coupling_combined

Function test_coupling_combined

tests/test_coupling.py:156–196  ·  view source on GitHub ↗
(hq_env: HqEnv)

Source from the content-addressed store, hash-verified

154
155
156def test_coupling_combined(hq_env: HqEnv):
157 def groups(job_id):
158 with open(default_task_output(job_id)) as f:
159 a, b = f.read().rstrip().split(";")
160 data1 = [int(x) // 10 for x in a.split(",")]
161 data2 = [int(x) // 10 for x in b.split(",")]
162 c1 = collections.Counter(data1)
163 c2 = collections.Counter(data2)
164 return sorted(c1.values()), sorted(c2.values())
165
166 hq_env.start_server()
167
168 hq_env.start_worker(
169 cpus="[[1, 2, 3, 4], [11, 12, 13, 14], [21, 22, 23, 24]]",
170 args=["--resource=foo=[[1, 2],[10,11],[22,21]]", "--coupling=cpus[0]:foo[0],cpus[1]:foo[1],cpus[2]:foo[2]"],
171 )
172
173 for i, (cpus, foos, expect) in enumerate(
174 [
175 ("6 tight", "2 tight", ([2, 4], [2])),
176 ("6 scatter", "2 scatter", ([2, 2, 2], [1, 1])),
177 ("6 compact", "2 compact", ([3, 3], [2])),
178 ("6 tight", "2 compact", ([2, 4], [2])),
179 ("6 compact", "2 tight", ([3, 3], [2])),
180 ("6 scatter", "2 tight", ([2, 2, 2], [2])),
181 ("6 scatter", "2 compact", ([2, 2, 2], [2])),
182 ],
183 1,
184 ):
185 hq_env.command(
186 [
187 "submit",
188 f"--cpus={cpus}",
189 "--resource",
190 f"foo={foos}",
191 "--",
192 *bash('echo "$HQ_RESOURCE_VALUES_cpus;$HQ_RESOURCE_VALUES_foo"'),
193 ]
194 )
195 wait_for_job_state(hq_env, i, "FINISHED")
196 assert groups(i) == expect

Callers

nothing calls this directly

Calls 6

bashFunction · 0.85
wait_for_job_stateFunction · 0.85
commandMethod · 0.80
groupsFunction · 0.70
start_serverMethod · 0.45
start_workerMethod · 0.45

Tested by

no test coverage detected