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

Function wait_for_alloc

tests/autoalloc/utils.py:130–155  ·  view source on GitHub ↗

Wait until an allocation has the given `state`. Assumes a single allocation queue.

(hq_env: HqEnv, state: str, allocation_id: str, timeout=DEFAULT_TIMEOUT)

Source from the content-addressed store, hash-verified

128
129
130def wait_for_alloc(hq_env: HqEnv, state: str, allocation_id: str, timeout=DEFAULT_TIMEOUT):
131 """
132 Wait until an allocation has the given `state`.
133 Assumes a single allocation queue.
134 """
135
136 last_table = None
137
138 def wait():
139 nonlocal last_table
140
141 last_table = hq_env.command(["alloc", "info", "1"], as_table=True)
142 for index in range(len(last_table)):
143 if (
144 last_table.get_column_value("ID")[index] == allocation_id
145 and last_table.get_column_value("State")[index] == state
146 ):
147 return True
148 return False
149
150 try:
151 wait_until(wait, timeout_s=timeout)
152 except TimeoutException as e:
153 if last_table is not None:
154 raise Exception(f"{e}, most recent table:\n{last_table}")
155 raise e
156
157
158def start_server_with_quick_refresh(hq_env: HqEnv, **kwargs) -> Popen:

Calls 1

wait_untilFunction · 0.50