Skip to content

Commit dc34a41

Browse files
authored
better process_replay context print [pr] (tinygrad#8856)
* better process_replay context print [pr] * test: revert push cast * Revert "test: revert push cast" This reverts commit 38a2aef.
1 parent 5b1fc4d commit dc34a41

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/external/process_replay/process_replay.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ def diff(offset:int, name:str, fxn:Callable) -> None:
6161
continue
6262
# try recreate
6363
try:
64-
with Context(**{k:v.value for k,v in args[-2].items() if k in ContextVar._cache and k != "DEBUG"}): good = fxn(*args[:-2])
64+
ctx_vars = {k:v.value for k,v in args[-2].items() if k != "DEBUG" and (var:=ContextVar._cache.get(k)) is not None and var.value != v.value}
65+
with Context(**ctx_vars): good = fxn(*args[:-2])
6566
if good is None: continue
6667
except Exception as e:
6768
changed += 1
@@ -72,7 +73,8 @@ def diff(offset:int, name:str, fxn:Callable) -> None:
7273
try: assert str(args[-1]) == str(good)
7374
except AssertionError:
7475
changed += 1
75-
for x in args[:-1]: logging.info(x)
76+
if ctx_vars: logging.info(ctx_vars)
77+
for x in args[:-2]: logging.info(x)
7678
changes = list(difflib.unified_diff(str(good).splitlines(), str(args[-1]).splitlines()))
7779
logging.info("\n".join(colored(line, "red" if line.startswith("-") else "green" if line.startswith("+") else None) for line in changes))
7880
warnings.warn("PROCESS REPLAY DETECTED CHANGE", ProcessReplayWarning)

0 commit comments

Comments
 (0)