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

Function test_coupling_alloc2

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

Source from the content-addressed store, hash-verified

105
106
107def test_coupling_alloc2(hq_env: HqEnv):
108 hq_env.start_server()
109
110 hq_env.command(
111 [
112 "submit",
113 "--cpus=4",
114 "--resource=foo=2",
115 "--",
116 *bash('echo "$HQ_RESOURCE_VALUES_cpus;$HQ_RESOURCE_VALUES_foo"'),
117 ]
118 )
119
120 hq_env.command(
121 [
122 "submit",
123 "--cpus=2",
124 "--resource=foo=4",
125 "--",
126 *bash('echo "$HQ_RESOURCE_VALUES_cpus;$HQ_RESOURCE_VALUES_foo"'),
127 ]
128 )
129
130 hq_env.start_worker(
131 cpus="[[1, 2, 3], [10, 11, 12], [21, 22, 23]]",
132 args=[
133 "--coupling=cpus[0]:foo[0],cpus[1]:foo[1],cpus[2]:foo[2]",
134 "--resource=ddd=sum(123)",
135 "--resource=foo=[[1, 2, 3],[10, 11, 12],[20, 21, 23]]",
136 ],
137 )
138
139 wait_for_job_state(hq_env, 1, "FINISHED")
140
141 def get_groups(data):
142 cpus, foos = (x.split(",") for x in data.rstrip().split(";"))
143 g = set()
144 for c in cpus:
145 g.add(int(c) // 10)
146 for f in foos:
147 g.add(int(f) // 10)
148 return g
149
150 with open(default_task_output(job_id=1), "r") as f:
151 assert len(get_groups(f.read())) == 2
152 with open(default_task_output(job_id=2), "r") as f:
153 assert len(get_groups(f.read())) == 2
154
155
156def test_coupling_combined(hq_env: HqEnv):

Callers

nothing calls this directly

Calls 7

bashFunction · 0.85
wait_for_job_stateFunction · 0.85
default_task_outputFunction · 0.85
get_groupsFunction · 0.85
commandMethod · 0.80
start_serverMethod · 0.45
start_workerMethod · 0.45

Tested by

no test coverage detected