Skip to content

Commit 108f807

Browse files
committed
test(web): fix slow webapi tests by patching time delays
1 parent 8f9544e commit 108f807

File tree

6 files changed

+12
-17
lines changed

6 files changed

+12
-17
lines changed

tests/test_web/test_webapi.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,6 @@ def mock_get_status(task_id):
224224
current_status = statuses[current_count]
225225
status_count[0] += 1
226226
return current_status
227-
# return TaskInfo(
228-
# status=current_status, taskName=TASK_NAME, taskId=task_id, realFlexUnit=1.0
229-
# )
230227

231228
run_count = [0]
232229
perc_dones = (1, 10, 20, 30, 100)
@@ -238,6 +235,8 @@ def mock_get_run_info(task_id):
238235
return perc_done, 1
239236

240237
monkeypatch.setattr("tidy3d.web.api.connect_util.REFRESH_TIME", 0.00001)
238+
monkeypatch.setattr(f"{api_path}.REFRESH_TIME", 0.00001)
239+
monkeypatch.setattr("tidy3d.web.api.container.web.REFRESH_TIME", 0.00001)
241240
monkeypatch.setattr(f"{api_path}.RUN_REFRESH_TIME", 0.00001)
242241
monkeypatch.setattr(f"{api_path}.get_status", mock_get_status)
243242
monkeypatch.setattr(f"{api_path}.get_run_info", mock_get_run_info)

tests/test_web/test_webapi_eme.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ def mock_get_status(task_id):
156156
current_status = statuses[current_count]
157157
status_count[0] += 1
158158
return current_status
159-
# return TaskInfo(
160-
# status=current_status, taskName=TASK_NAME, taskId=task_id, realFlexUnit=1.0
161-
# )
162159

163160
run_count = [0]
164161
perc_dones = (1, 10, 20, 30, 100)
@@ -170,6 +167,8 @@ def mock_get_run_info(task_id):
170167
return perc_done, 1
171168

172169
monkeypatch.setattr("tidy3d.web.api.connect_util.REFRESH_TIME", 0.00001)
170+
monkeypatch.setattr(f"{api_path}.REFRESH_TIME", 0.00001)
171+
monkeypatch.setattr("tidy3d.web.api.container.web.REFRESH_TIME", 0.00001)
173172
monkeypatch.setattr(f"{api_path}.RUN_REFRESH_TIME", 0.00001)
174173
monkeypatch.setattr(f"{api_path}.get_status", mock_get_status)
175174
monkeypatch.setattr(f"{api_path}.get_run_info", mock_get_run_info)

tests/test_web/test_webapi_heat.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ def mock_get_status(task_id):
153153
current_status = statuses[current_count]
154154
status_count[0] += 1
155155
return current_status
156-
# return TaskInfo(
157-
# status=current_status, taskName=TASK_NAME, taskId=task_id, realFlexUnit=1.0
158-
# )
159156

160157
run_count = [0]
161158
perc_dones = (1, 10, 20, 30, 100)
@@ -167,6 +164,8 @@ def mock_get_run_info(task_id):
167164
return perc_done, 1
168165

169166
monkeypatch.setattr("tidy3d.web.api.connect_util.REFRESH_TIME", 0.00001)
167+
monkeypatch.setattr(f"{api_path}.REFRESH_TIME", 0.00001)
168+
monkeypatch.setattr("tidy3d.web.api.container.web.REFRESH_TIME", 0.00001)
170169
monkeypatch.setattr(f"{api_path}.RUN_REFRESH_TIME", 0.00001)
171170
monkeypatch.setattr(f"{api_path}.get_status", mock_get_status)
172171
monkeypatch.setattr(f"{api_path}.get_run_info", mock_get_run_info)

tests/test_web/test_webapi_mode.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ def mock_get_status(task_id):
189189
current_status = statuses[current_count]
190190
status_count[0] += 1
191191
return current_status
192-
# return TaskInfo(
193-
# status=current_status, taskName=TASK_NAME, taskId=task_id, realFlexUnit=1.0
194-
# )
195192

196193
run_count = [0]
197194
perc_dones = (1, 10, 20, 30, 100)
@@ -203,6 +200,8 @@ def mock_get_run_info(task_id):
203200
return perc_done, 1
204201

205202
monkeypatch.setattr("tidy3d.web.api.connect_util.REFRESH_TIME", 0.00001)
203+
monkeypatch.setattr(f"{api_path}.REFRESH_TIME", 0.00001)
204+
monkeypatch.setattr("tidy3d.web.api.container.web.REFRESH_TIME", 0.00001)
206205
monkeypatch.setattr(f"{api_path}.RUN_REFRESH_TIME", 0.00001)
207206
monkeypatch.setattr(f"{api_path}.get_status", mock_get_status)
208207
monkeypatch.setattr(f"{api_path}.get_run_info", mock_get_run_info)

tests/test_web/test_webapi_mode_sim.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ def mock_get_status(task_id):
185185
current_status = statuses[current_count]
186186
status_count[0] += 1
187187
return current_status
188-
# return TaskInfo(
189-
# status=current_status, taskName=TASK_NAME, taskId=task_id, realFlexUnit=1.0
190-
# )
191188

192189
run_count = [0]
193190
perc_dones = (1, 10, 20, 30, 100)
@@ -199,6 +196,8 @@ def mock_get_run_info(task_id):
199196
return perc_done, 1
200197

201198
monkeypatch.setattr("tidy3d.web.api.connect_util.REFRESH_TIME", 0.00001)
199+
monkeypatch.setattr(f"{api_path}.REFRESH_TIME", 0.00001)
200+
monkeypatch.setattr("tidy3d.web.api.container.web.REFRESH_TIME", 0.00001)
202201
monkeypatch.setattr(f"{api_path}.RUN_REFRESH_TIME", 0.00001)
203202
monkeypatch.setattr(f"{api_path}.get_status", mock_get_status)
204203
monkeypatch.setattr(f"{api_path}.get_run_info", mock_get_run_info)

tidy3d/web/api/webapi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,14 +598,14 @@ def monitor_preprocess() -> None:
598598
else:
599599
while get_status(task_id) == "running":
600600
perc_done, _ = get_run_info(task_id)
601-
time.sleep(1.0)
601+
time.sleep(RUN_REFRESH_TIME)
602602

603603
else:
604604
# non-verbose case, just keep checking until status is not running or perc_done >= 100
605605
perc_done, _ = get_run_info(task_id)
606606
while perc_done is not None and perc_done < 100 and get_status(task_id) == "running":
607607
perc_done, field_decay = get_run_info(task_id)
608-
time.sleep(1.0)
608+
time.sleep(RUN_REFRESH_TIME)
609609

610610
# post processing
611611
if verbose:

0 commit comments

Comments
 (0)