@@ -285,7 +285,7 @@ def _test_load_simulation_if_cached(monkeypatch, tmp_path, basic_simulation):
285285 assert counters == {"upload" : 1 , "start" : 1 , "monitor" : 1 , "download" : 1 }
286286 assert len (cache ) == 1
287287
288- sim_data_from_cache = load_simulation_if_cached (basic_simulation )
288+ sim_data_from_cache = load_simulation_if_cached (basic_simulation , path = tmp_path / "tmp.hdf5" )
289289 assert sim_data_from_cache is not None
290290 assert sim_data_from_cache .simulation == basic_simulation
291291
@@ -296,28 +296,28 @@ def _test_load_simulation_if_cached(monkeypatch, tmp_path, basic_simulation):
296296
297297def _test_mode_solver_caching (monkeypatch , tmp_path ):
298298 counters = _patch_run_pipeline (monkeypatch )
299-
299+ tmp_file = tmp_path / "tmp.hdf5"
300300 # store in cache
301301 mode_sim = make_mode_sim ()
302- mode_sim_data = web .run (mode_sim )
302+ mode_sim_data = web .run (mode_sim , path = tmp_file )
303303
304304 # test basic loading from cache
305- from_cache_data = load_simulation_if_cached (mode_sim )
305+ from_cache_data = load_simulation_if_cached (mode_sim , path = tmp_file )
306306 assert from_cache_data is not None
307307 assert isinstance (from_cache_data , _FakeStubData )
308308 assert mode_sim_data .simulation == from_cache_data .simulation
309309
310310 # test loading from run
311311 _reset_counters (counters )
312- mode_sim_data_run = web .run (mode_sim )
312+ mode_sim_data_run = web .run (mode_sim , path = tmp_file )
313313 assert counters ["download" ] == 0
314314 assert isinstance (mode_sim_data_run , _FakeStubData )
315315 assert mode_sim_data .simulation == mode_sim_data_run .simulation
316316
317317 # test loading from job
318318 _reset_counters (counters )
319319 job = Job (simulation = mode_sim , task_name = "test" )
320- job_data = job .run ()
320+ job_data = job .run (path = tmp_file )
321321 assert counters ["download" ] == 0
322322 assert isinstance (job_data , _FakeStubData )
323323 assert mode_sim_data .simulation == job_data .simulation
@@ -334,14 +334,14 @@ def _test_mode_solver_caching(monkeypatch, tmp_path):
334334 cache = resolve_local_cache (True )
335335 # test storing via job
336336 cache .clear ()
337- Job (simulation = mode_sim , task_name = "test" ).run ()
338- assert load_simulation_if_cached (mode_sim ) is not None
337+ Job (simulation = mode_sim , task_name = "test" ).run (path = tmp_file )
338+ assert load_simulation_if_cached (mode_sim , path = tmp_file ) is not None
339339
340340 # test storing via batch
341341 cache .clear ()
342342 batch_mode_data = Batch (simulations = {"sim1" : mode_sim }).run (path_dir = tmp_path )
343343 _ = batch_mode_data ["sim1" ] # access to store
344- assert load_simulation_if_cached (mode_sim ) is not None
344+ assert load_simulation_if_cached (mode_sim , path = tmp_file ) is not None
345345
346346
347347def _test_run_cache_hit_async (monkeypatch , basic_simulation , tmp_path ):
@@ -382,7 +382,7 @@ def _test_run_cache_hit_async(monkeypatch, basic_simulation, tmp_path):
382382 assert len (cache ) == 3
383383
384384
385- def _test_verbosity (monkeypatch , basic_simulation ):
385+ def _test_verbosity (monkeypatch , basic_simulation , tmp_path ):
386386 _CSI_RE = re .compile (r"\x1b\[[0-?]*[ -/]*[@-~]" ) # ANSI CSI
387387 _OSC8_RE = re .compile (r"\x1b\]8;.*?(?:\x1b\\|\x07)" , re .DOTALL ) # OSC-8 hyperlinks
388388
@@ -403,8 +403,8 @@ def _normalize_console_text(s: str) -> str:
403403 _reset_counters (counters )
404404 sim2 = basic_simulation .updated_copy (shutoff = 1e-4 )
405405 sim3 = basic_simulation .updated_copy (shutoff = 1e-3 )
406-
407- run (basic_simulation , verbose = True ) # seed cache
406+ tmp_file = tmp_path / "tmp.hdf5"
407+ run (basic_simulation , verbose = True , path = tmp_file ) # seed cache
408408
409409 log_mod = importlib .import_module ("tidy3d.log" )
410410
@@ -424,22 +424,22 @@ def _normalize_console_text(s: str) -> str:
424424 buf .seek (0 )
425425
426426 # test for load_simulation_if_cached
427- sim_data = load_simulation_if_cached (basic_simulation , verbose = True )
427+ sim_data = load_simulation_if_cached (basic_simulation , verbose = True , path = tmp_file )
428428 assert sim_data is not None
429429 assert "Loading simulation from" in buf .getvalue (), (
430430 f"Expected 'Loading simulation from' in log, got '{ buf .getvalue ()} '"
431431 )
432432
433433 buf .truncate (0 )
434434 buf .seek (0 )
435- load_simulation_if_cached (basic_simulation , verbose = False )
435+ load_simulation_if_cached (basic_simulation , verbose = False , path = tmp_file )
436436 assert sim_data is not None
437437 assert buf .getvalue ().strip () == "" , f"Expected empty log, got '{ buf .getvalue ()} '"
438438
439439 # test for batched runs
440440 buf .truncate (0 )
441441 buf .seek (0 )
442- run ([basic_simulation , sim3 ], verbose = True )
442+ run ([basic_simulation , sim3 ], verbose = True , path = tmp_path )
443443 txt = _normalize_console_text (buf .getvalue ())
444444 assert "Got 1 simulation from cache" in txt , (
445445 f"Expected 'Got 1 simulation from cache' in log, got '{ buf .getvalue ()} '"
@@ -448,13 +448,13 @@ def _normalize_console_text(s: str) -> str:
448448 # if some found
449449 buf .truncate (0 )
450450 buf .seek (0 )
451- run ([basic_simulation , sim2 ], verbose = False )
451+ run ([basic_simulation , sim2 ], verbose = False , path = tmp_path )
452452 assert buf .getvalue ().strip () == "" , f"Expected empty log, got '{ buf .getvalue ()} '"
453453
454454 # if all found
455455 buf .truncate (0 )
456456 buf .seek (0 )
457- run ([basic_simulation , sim2 ], verbose = False )
457+ run ([basic_simulation , sim2 ], verbose = False , path = tmp_path )
458458 assert buf .getvalue ().strip () == "" , f"Expected empty log, got '{ buf .getvalue ()} '"
459459
460460 finally :
@@ -467,7 +467,7 @@ def _test_job_run_cache(monkeypatch, basic_simulation, tmp_path):
467467 cache = resolve_local_cache (use_cache = True )
468468 cache .clear ()
469469 job = Job (simulation = basic_simulation , task_name = "test" )
470- job .run ()
470+ job .run (path = tmp_path / "tmp.hdf5" )
471471
472472 assert len (cache ) == 1
473473
@@ -485,7 +485,7 @@ def _test_job_run_cache(monkeypatch, basic_simulation, tmp_path):
485485 assert os .path .exists (out2_path )
486486
487487
488- def _test_autograd_cache (monkeypatch , request ):
488+ def _test_autograd_cache (monkeypatch , request , tmp_path ):
489489 counters = _patch_run_pipeline (monkeypatch )
490490
491491 # "Original" rule: the one autograd uses by default
@@ -526,7 +526,7 @@ def _restore_make_dict_vjp():
526526 def objective (params ):
527527 sim = make_sim (params )
528528 sim .attrs ["params" ] = params
529- sim_data = run_autograd (sim )
529+ sim_data = run_autograd (sim , path = tmp_path / "tmp.hdf5" )
530530 value = postprocess (sim_data )
531531 return value
532532
@@ -823,9 +823,9 @@ def test_cache_sequential(
823823 _test_cache_stats_sync (monkeypatch , tmp_path_factory , basic_simulation )
824824 _test_run_cache_hit_async (monkeypatch , basic_simulation , tmp_path )
825825 _test_job_run_cache (monkeypatch , basic_simulation , tmp_path )
826- _test_autograd_cache (monkeypatch , request )
826+ _test_autograd_cache (monkeypatch , request , tmp_path )
827827 _test_configure_cache_roundtrip (monkeypatch , tmp_path )
828828 _test_store_and_fetch_do_not_iterate (monkeypatch , tmp_path , basic_simulation )
829829 _test_mode_solver_caching (monkeypatch , tmp_path )
830- _test_verbosity (monkeypatch , basic_simulation )
830+ _test_verbosity (monkeypatch , basic_simulation , tmp_path )
831831 _test_cache_cli_commands (monkeypatch , tmp_path_factory , basic_simulation )
0 commit comments