Skip to content

Commit

Permalink
move to legacy: trace_local.py
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtruong committed Aug 27, 2024
1 parent a9bee1f commit 8a4dc80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion weave/legacy/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
environment,
errors,
ref_base,
trace_local,
)
from weave import weave_types as types

Expand Down Expand Up @@ -41,6 +40,7 @@
op_def,
op_execute,
op_policy,
trace_local,
value_or_error,
wandb_api,
)
Expand Down
18 changes: 9 additions & 9 deletions weave/trace_local.py → weave/legacy/trace_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

from weave.legacy import artifact_local, graph, op_def, op_policy, runs

from . import (
from .. import (
ref_base,
storage,
weave_internal,
)
from . import weave_types as types
from .. import weave_types as types


@dataclasses.dataclass
Expand All @@ -21,7 +21,7 @@ class RunKey:
id: str


def _value_id(val):
def _value_id(val): # type: ignore
# Important, do not include the type here, as it can change.
# This happens because you can have a ref to an item that's in a list.
# The list's object_type can change as items are appended to it.
Expand All @@ -44,7 +44,7 @@ def make_run_key(
else:
hashable_inputs = {}
for name, obj in inputs_refs.items():
hashable_inputs[name] = _value_id(obj)
hashable_inputs[name] = _value_id(obj) # type: ignore[no-untyped-call]
hash_val = {
"op_name": op_def.name,
"op_version": op_def.version,
Expand Down Expand Up @@ -89,7 +89,7 @@ def _single_run(self, run_key: RunKey) -> graph.Node[runs.Run]:
types.RunType(),
)

def _run_table(self, run_key: RunKey):
def _run_table(self, run_key: RunKey): # type: ignore
table_uri = artifact_local.WeaveLocalArtifactURI(
f"run-{run_key.op_simple_name}", "latest", "obj"
)
Expand All @@ -99,7 +99,7 @@ def _run_table(self, run_key: RunKey):
types.List(types.RunType()),
)

def _should_save_to_table(self, run_key: RunKey):
def _should_save_to_table(self, run_key: RunKey): # type: ignore
# Restricted to just a couple ops for now.
# A NOTE: for the future, async ops definitely can't be saved to
# table (until we have safe table writes)
Expand All @@ -120,10 +120,10 @@ def get_run(self, run_key: RunKey) -> graph.Node[runs.Run]:
def get_run_val(self, run_key: RunKey) -> typing.Optional[runs.Run]:
from weave.legacy import execute_fast

res = execute_fast._execute_fn_no_engine(None, None, self.get_run(run_key))
res = execute_fast._execute_fn_no_engine(None, None, self.get_run(run_key)) # type: ignore[no-untyped-call]
return res

def save_run(self, run: runs.Run):
def save_run(self, run: runs.Run): # type: ignore
from weave.legacy.ops_primitives import weave_api

run_key = RunKey(run.op_name, run.id)
Expand All @@ -132,7 +132,7 @@ def save_run(self, run: runs.Run):
else:
weave_api.set(self._single_run(run_key), run, {})

def save_run_output(self, od: op_def.OpDef, run_key: RunKey, output: typing.Any):
def save_run_output(self, od: op_def.OpDef, run_key: RunKey, output: typing.Any): # type: ignore
if not od.pure:
# If an op is impure, its output is saved to a name that does not
# include run ID. This means consuming pure runs will hit cache if
Expand Down

0 comments on commit 8a4dc80

Please sign in to comment.