Skip to content

Commit

Permalink
move to legacy: ref_base
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtruong committed Aug 27, 2024
1 parent 39d508b commit 9e50b63
Show file tree
Hide file tree
Showing 29 changed files with 41 additions and 39 deletions.
2 changes: 1 addition & 1 deletion weave/legacy/arrow/list_.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from weave import (
errors,
ref_base,
ref_util,
weave_internal,
)
Expand All @@ -27,6 +26,7 @@
op_def,
op_def_type,
node_ref,
ref_base,
)
from weave.legacy.arrow.arrow import (
ArrowWeaveListType,
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/artifact_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import typing

from weave import weave_types as types
from weave import ref_base
from weave.legacy import ref_base


class Artifact:
Expand Down
4 changes: 2 additions & 2 deletions weave/legacy/artifact_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import os
import typing

from weave import errors, ref_base, ref_util
from weave import errors, ref_util
from weave import weave_types as types
from weave.legacy import artifact_base, file_base, object_context, uris
from weave.legacy import artifact_base, file_base, object_context, ref_base, uris
from weave.legacy.language_features.tagging import tag_store

if typing.TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/artifact_mem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from . import artifact_base
from weave import weave_types as types
from weave import errors
from weave import ref_base
from weave.legacy import ref_base


class MemArtifact(artifact_base.Artifact):
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from weave import (
environment,
errors,
ref_base,
)
from weave import weave_types as types

Expand All @@ -25,6 +24,7 @@
from weave.legacy import (
engine_trace,
parallelism,
ref_base,
registry_mem,
box,
compile,
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/execute_fast.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from weave import (
errors,
ref_base,
weave_internal,
)
from weave import weave_types as types
from weave.legacy import (
engine_trace,
ref_base,
registry_mem,
box,
compile,
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/graph_mapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from weave import ref_base
from weave.legacy import ref_base
from weave import weave_types as types
from weave.legacy import graph, mappers, node_ref
from weave.legacy import mappers_python_def as mappers_python
Expand Down
3 changes: 2 additions & 1 deletion weave/legacy/mappers_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pyarrow as pa

from weave import errors, ref_base
from weave import errors
from weave import weave_types as types
from weave.legacy import (
arrow_util,
Expand All @@ -15,6 +15,7 @@
mappers_weave,
node_ref,
partial_object,
ref_base,
)
from weave.legacy import mappers_python_def as mappers_python
from weave.legacy.arrow import arrow
Expand Down
3 changes: 2 additions & 1 deletion weave/legacy/mappers_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import dataclasses
import typing

from weave import errors, ref_base, storage, weave_internal
from weave import errors, storage, weave_internal
from weave import weave_types as types
from weave.legacy.node_ref import ref_to_node

Expand All @@ -15,6 +15,7 @@
graph,
mappers,
mappers_python_def,
ref_base,
)
from weave.legacy.artifact_wandb import likely_commit_hash
from weave.legacy.language_features.tagging import tag_store, tagged_value_type
Expand Down
3 changes: 2 additions & 1 deletion weave/legacy/mappers_python_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import math
import typing

from weave import errors, ref_base, storage
from weave import errors, storage
from weave import weave_types as types
from weave.legacy import (
artifact_fs,
box,
mappers,
mappers_python,
mappers_weave,
ref_base,
val_const,
)
from weave.legacy import timestamp as weave_timestamp
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/node_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from weave.legacy import graph

from .. import ref_base
from . import ref_base

# Notes for the future:
# - I added list.lookup to lookup rows in a list by ID. I think we probably should
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/object_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import Any

if typing.TYPE_CHECKING:
from weave import ref_base
from weave.legacy import ref_base
from weave import weave_types as types
from weave.legacy import box, uris

Expand Down
4 changes: 2 additions & 2 deletions weave/legacy/ops_primitives/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import typing

from weave.query_api import op
from weave import ref_base, types
from weave.legacy import artifact_fs
from weave import types
from weave.legacy import artifact_fs, ref_base
from weave.legacy.artifact_local import WORKING_DIR_PREFIX, LocalArtifact


Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/ops_primitives/weave_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

from weave import (
errors,
ref_base,
storage,
weave_internal,
)
from weave import weave_types as types
from weave.query_api import mutation, op, weave_class
from weave.legacy import (
ref_base,
registry_mem,
artifact_fs,
artifact_local,
Expand Down
11 changes: 5 additions & 6 deletions weave/ref_base.py → weave/legacy/ref_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
from typing import Sequence

from weave.client_context import weave_client as weave_client_context
from weave.legacy import box, context_state, object_context
from weave.legacy import box, context_state, object_context, uris
from weave.legacy.language_features.tagging import tag_store

from . import errors
from . import weave_types as types
from .legacy import uris
from .. import errors
from .. import weave_types as types

# We store Refs here if we can't attach them directly to the object
REFS: weakref.WeakValueDictionary[int, "Ref"] = weakref.WeakValueDictionary()

if typing.TYPE_CHECKING:
from . import weave_types as types
from .trace import weave_client
from .. import weave_types as types
from ..trace import weave_client


def _map_to_ref_strs(obj: typing.Any) -> typing.Any:
Expand Down
4 changes: 2 additions & 2 deletions weave/legacy/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from IPython.display import IFrame, display

from weave.legacy import artifact_fs, context, graph, ops, node_ref, panel
from weave import errors, ref_base, storage, util
from weave.legacy import artifact_fs, context, graph, ops, node_ref, panel, ref_base
from weave import errors, storage, util
from . import usage_analytics
from .. import weave_types as types
from . import weavejs_fixes
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/trace_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from weave.legacy import artifact_local, graph, runs

from .. import ref_base
from . import ref_base
from . import errors
from .. import weave_types as types

Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/trace_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from typing import Mapping

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

from .. import (
ref_base,
storage,
weave_internal,
)
Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/uris.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .. import errors

if typing.TYPE_CHECKING:
from .. import ref_base
from . import ref_base


@dataclasses.dataclass
Expand Down
2 changes: 1 addition & 1 deletion weave/query_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from weave.legacy import graph_mapper as _graph_mapper

from . import storage as _storage
from . import ref_base as _ref_base
from .legacy import ref_base as _ref_base
from weave.legacy import wandb_api as _wandb_api

from . import weave_internal as _weave_internal
Expand Down
2 changes: 1 addition & 1 deletion weave/ref_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def val_with_relative_ref(
) -> typing.Any:
from weave.legacy import context_state

from . import ref_base
from .legacy import ref_base

# If we already have a ref, resolve it
if isinstance(child_object, ref_base.Ref):
Expand Down
3 changes: 2 additions & 1 deletion weave/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
box,
graph,
mappers_python,
ref_base,
timestamp,
)

from . import errors, ref_base
from . import errors
from . import weave_types as types

Ref = ref_base.Ref
Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_mutation2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import weave
from weave import ref_base
from weave.legacy import uris
from weave.legacy import ref_base, uris

from ... import weave_internal

Expand Down
2 changes: 1 addition & 1 deletion weave/tests/legacy/test_wb_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _test_basic_publish(user_fixture):
uri
== f"wandb-artifact:///{user_fixture.username}/weave/list:0cdf3358dc939f961ca9/obj"
)
assert weave.ref_base.Ref.from_str(uri).get() == [1, 2, 3]
assert weave.legacy.ref_base.Ref.from_str(uri).get() == [1, 2, 3]


# Example of end to end integration test
Expand Down
2 changes: 1 addition & 1 deletion weave/tests/trace/test_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

import weave
from weave import Dataset, Evaluation, Model, ref_base
from weave import Dataset, Evaluation, Model
from weave.flow.scorer import MultiTaskBinaryClassificationF1

pytestmark = pytest.mark.webtest
Expand Down
2 changes: 1 addition & 1 deletion weave/tests/trace/test_weaveflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pydantic import Field

import weave
from weave import ref_base
from weave.legacy import ref_base

pytestmark = pytest.mark.trace

Expand Down
2 changes: 1 addition & 1 deletion weave/trace/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import numpy as np

from weave.ref_base import Ref
from weave.legacy.ref_base import Ref

T = TypeVar("T")

Expand Down
2 changes: 1 addition & 1 deletion weave/trace/weave_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
)

if typing.TYPE_CHECKING:
from .. import ref_base
from ..legacy import ref_base


# Controls if objects can have refs to projects not the WeaveClient project.
Expand Down
4 changes: 2 additions & 2 deletions weave/weave_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def type_class_of(obj):

@staticmethod
def type_of(obj: typing.Any) -> "Type":
from . import ref_base
from weave.legacy import ref_base

if (
context_state.ref_tracking_enabled()
Expand Down Expand Up @@ -1381,7 +1381,7 @@ def _is_assignable_to(self, other_type) -> typing.Optional[bool]:
return None

def save_instance(self, obj, artifact, name):
from . import ref_base
from weave.legacy import ref_base

obj_ref = ref_base.get_ref(obj)
if obj_ref is None:
Expand Down

0 comments on commit 9e50b63

Please sign in to comment.