Skip to content

Commit 1fac5c3

Browse files
fix(tidy3d): FXC-4089 fix hashing in web.run()
1 parent 79d8f19 commit 1fac5c3

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

tests/test_web/test_local_cache.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,13 @@ def _normalize_console_text(s: str) -> str:
415415
f"Expected 'Got 1 simulation from cache' in log, got '{buf.getvalue()}'"
416416
)
417417

418+
# if some found
419+
buf.truncate(0)
420+
buf.seek(0)
421+
run([basic_simulation, sim2], verbose=False)
422+
assert buf.getvalue().strip() == "", f"Expected empty log, got '{buf.getvalue()}'"
423+
424+
# if all found
418425
buf.truncate(0)
419426
buf.seek(0)
420427
run([basic_simulation, sim2], verbose=False)

tidy3d/web/api/container.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,9 @@ def run(
870870
self.start(priority=priority)
871871
self.monitor(path_dir=path_dir, download_on_success=True)
872872
else:
873-
console = get_logging_console()
874-
console.log("Found all simulations in cache.")
873+
if self.verbose:
874+
console = get_logging_console()
875+
console.log("Found all simulations in cache.")
875876
self.download(path_dir=path_dir) # moves cache files
876877
return self.load(path_dir=path_dir, skip_download=True)
877878

tidy3d/web/api/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _collect_by_hash(
3737
if found is None:
3838
found = {}
3939
if isinstance(node, WorkflowType):
40-
found[str(hash(node))] = node
40+
found[node._hash_self()] = node
4141
return found
4242
if isinstance(node, (list, tuple)):
4343
for v in node:
@@ -63,7 +63,7 @@ def _reconstruct_by_hash(node: RunInput, h2data: dict[str, WorkflowDataType]) ->
6363

6464
def _recur(n: RunInput) -> RunOutput:
6565
if isinstance(n, WorkflowType):
66-
h = str(hash(n))
66+
h = n._hash_self()
6767
data = h2data[h]
6868
if h in seen:
6969
return data.copy()

0 commit comments

Comments
 (0)