Skip to content

Commit

Permalink
snoopy => tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNuevoDia committed Nov 25, 2024
1 parent 0c1f989 commit 6087230
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dspy/evaluate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from .auto_evaluation import *
from .evaluate import Evaluate
from .metrics import *
from .snoopy import snoopy
from .tracer import tracer
16 changes: 8 additions & 8 deletions dspy/evaluate/snoopy.py → dspy/evaluate/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def my_function():
from functools import wraps, partial
from inspect import getsourcelines

from snoop import Config as SnoopConfig
from snoop import Config


@dataclass
class SnoopFile:
class Trace:
lines: list[str] = field(default_factory=list)

def write(self, line: str):
Expand All @@ -60,17 +60,17 @@ def source_code(f):
return "\n".join(f"{i:>5} | {line}".rstrip() for i, line in enumerate(lines, 1))


def snoopy(f=None, **snoop_kwargs):
def tracer(f=None, **snoop_kwargs):
if not f:
return partial(snoopy, **snoop_kwargs)
return partial(tracer, **snoop_kwargs)

@wraps(f)
def wrapper(*args, **kwargs):
trace = SnoopFile()
snoopy = SnoopConfig(out=trace, color=False, columns=[])
wrapper.snoopy = snoopy
trace = Trace()
snoop = Config(out=trace, color=False, columns=[])
wrapper.snoop = snoop
wrapper.trace = trace
return snoopy.snoop(f, **snoop_kwargs)(*args, **kwargs)
return snoop.snoop(f, **snoop_kwargs)(*args, **kwargs)

wrapper.source = source_code(f)

Expand Down

0 comments on commit 6087230

Please sign in to comment.