diff --git a/weave/legacy/arrow/list_.py b/weave/legacy/arrow/list_.py index 6db149220d57..f8a7f09bbb3b 100644 --- a/weave/legacy/arrow/list_.py +++ b/weave/legacy/arrow/list_.py @@ -12,7 +12,6 @@ from weave import ( errors, - ref_base, ref_util, weave_internal, ) @@ -27,6 +26,7 @@ op_def, op_def_type, node_ref, + ref_base, ) from weave.legacy.arrow.arrow import ( ArrowWeaveListType, diff --git a/weave/legacy/artifact_base.py b/weave/legacy/artifact_base.py index 9e62e34fa83e..02b2e35d2132 100644 --- a/weave/legacy/artifact_base.py +++ b/weave/legacy/artifact_base.py @@ -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: diff --git a/weave/legacy/artifact_fs.py b/weave/legacy/artifact_fs.py index b753b5019748..f09e110e6123 100644 --- a/weave/legacy/artifact_fs.py +++ b/weave/legacy/artifact_fs.py @@ -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: diff --git a/weave/legacy/artifact_mem.py b/weave/legacy/artifact_mem.py index 5e6f63f9159a..58471d6460f4 100644 --- a/weave/legacy/artifact_mem.py +++ b/weave/legacy/artifact_mem.py @@ -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): diff --git a/weave/legacy/execute.py b/weave/legacy/execute.py index 916d9646f825..8c9bb02475e8 100644 --- a/weave/legacy/execute.py +++ b/weave/legacy/execute.py @@ -12,7 +12,6 @@ from weave import ( environment, errors, - ref_base, ) from weave import weave_types as types @@ -25,6 +24,7 @@ from weave.legacy import ( engine_trace, parallelism, + ref_base, registry_mem, box, compile, diff --git a/weave/legacy/execute_fast.py b/weave/legacy/execute_fast.py index 91a8e640b5b5..f4b571c86eae 100644 --- a/weave/legacy/execute_fast.py +++ b/weave/legacy/execute_fast.py @@ -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, diff --git a/weave/legacy/graph_mapper.py b/weave/legacy/graph_mapper.py index 8e0b6cce6269..f2c68399433f 100644 --- a/weave/legacy/graph_mapper.py +++ b/weave/legacy/graph_mapper.py @@ -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 diff --git a/weave/legacy/mappers_arrow.py b/weave/legacy/mappers_arrow.py index 6b3ed3765776..2f1ca904ef17 100644 --- a/weave/legacy/mappers_arrow.py +++ b/weave/legacy/mappers_arrow.py @@ -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, @@ -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 diff --git a/weave/legacy/mappers_publisher.py b/weave/legacy/mappers_publisher.py index f9facd494e72..2e57541b60e4 100644 --- a/weave/legacy/mappers_publisher.py +++ b/weave/legacy/mappers_publisher.py @@ -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 @@ -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 diff --git a/weave/legacy/mappers_python_def.py b/weave/legacy/mappers_python_def.py index 40359e01d8c9..88a38b59af1c 100644 --- a/weave/legacy/mappers_python_def.py +++ b/weave/legacy/mappers_python_def.py @@ -4,7 +4,7 @@ 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, @@ -12,6 +12,7 @@ mappers, mappers_python, mappers_weave, + ref_base, val_const, ) from weave.legacy import timestamp as weave_timestamp diff --git a/weave/legacy/node_ref.py b/weave/legacy/node_ref.py index 9c19030ba8f4..47edbc6804bf 100644 --- a/weave/legacy/node_ref.py +++ b/weave/legacy/node_ref.py @@ -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 diff --git a/weave/legacy/object_context.py b/weave/legacy/object_context.py index 836fd054151b..b8d916063e27 100644 --- a/weave/legacy/object_context.py +++ b/weave/legacy/object_context.py @@ -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 diff --git a/weave/legacy/ops_primitives/artifacts.py b/weave/legacy/ops_primitives/artifacts.py index d48f86d9da2f..d05c9223c8b3 100644 --- a/weave/legacy/ops_primitives/artifacts.py +++ b/weave/legacy/ops_primitives/artifacts.py @@ -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 diff --git a/weave/legacy/ops_primitives/weave_api.py b/weave/legacy/ops_primitives/weave_api.py index 33ace6416b4d..d59113a29977 100644 --- a/weave/legacy/ops_primitives/weave_api.py +++ b/weave/legacy/ops_primitives/weave_api.py @@ -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, diff --git a/weave/ref_base.py b/weave/legacy/ref_base.py similarity index 96% rename from weave/ref_base.py rename to weave/legacy/ref_base.py index 120ff9fed6d7..e7742d9eb655 100644 --- a/weave/ref_base.py +++ b/weave/legacy/ref_base.py @@ -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: diff --git a/weave/legacy/show.py b/weave/legacy/show.py index df57367e12f7..92ae3f7cf169 100644 --- a/weave/legacy/show.py +++ b/weave/legacy/show.py @@ -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 diff --git a/weave/legacy/trace_legacy.py b/weave/legacy/trace_legacy.py index 3264585672d7..3d9e6529cc48 100644 --- a/weave/legacy/trace_legacy.py +++ b/weave/legacy/trace_legacy.py @@ -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 diff --git a/weave/legacy/trace_local.py b/weave/legacy/trace_local.py index bc1376d5e353..b210d313b094 100644 --- a/weave/legacy/trace_local.py +++ b/weave/legacy/trace_local.py @@ -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, ) diff --git a/weave/legacy/uris.py b/weave/legacy/uris.py index dc1e562b80ea..7ce5150f23bd 100644 --- a/weave/legacy/uris.py +++ b/weave/legacy/uris.py @@ -5,7 +5,7 @@ from .. import errors if typing.TYPE_CHECKING: - from .. import ref_base + from . import ref_base @dataclasses.dataclass diff --git a/weave/query_api.py b/weave/query_api.py index 908c7e526fb9..9f2140b84160 100644 --- a/weave/query_api.py +++ b/weave/query_api.py @@ -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 diff --git a/weave/ref_util.py b/weave/ref_util.py index d2adf5a005fb..968a584ca61b 100644 --- a/weave/ref_util.py +++ b/weave/ref_util.py @@ -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): diff --git a/weave/storage.py b/weave/storage.py index 8f0336d37c86..c87c1db40605 100644 --- a/weave/storage.py +++ b/weave/storage.py @@ -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 diff --git a/weave/tests/legacy/test_mutation2.py b/weave/tests/legacy/test_mutation2.py index 9fe786a35787..d344f10b0f9f 100644 --- a/weave/tests/legacy/test_mutation2.py +++ b/weave/tests/legacy/test_mutation2.py @@ -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 diff --git a/weave/tests/legacy/test_wb_end_to_end.py b/weave/tests/legacy/test_wb_end_to_end.py index 1529cfff6553..2232079248dc 100644 --- a/weave/tests/legacy/test_wb_end_to_end.py +++ b/weave/tests/legacy/test_wb_end_to_end.py @@ -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 diff --git a/weave/tests/trace/test_evaluate.py b/weave/tests/trace/test_evaluate.py index 0af269f1c888..b855eea3def5 100644 --- a/weave/tests/trace/test_evaluate.py +++ b/weave/tests/trace/test_evaluate.py @@ -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 diff --git a/weave/tests/trace/test_weaveflow.py b/weave/tests/trace/test_weaveflow.py index ca3218dc98fb..a41f4eba9d4a 100644 --- a/weave/tests/trace/test_weaveflow.py +++ b/weave/tests/trace/test_weaveflow.py @@ -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 diff --git a/weave/trace/box.py b/weave/trace/box.py index 6662aedc113b..1c39bf5e39fe 100644 --- a/weave/trace/box.py +++ b/weave/trace/box.py @@ -10,7 +10,7 @@ import numpy as np -from weave.ref_base import Ref +from weave.legacy.ref_base import Ref T = TypeVar("T") diff --git a/weave/trace/weave_client.py b/weave/trace/weave_client.py index ce2ea38eea1c..32a382f59990 100644 --- a/weave/trace/weave_client.py +++ b/weave/trace/weave_client.py @@ -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. diff --git a/weave/weave_types.py b/weave/weave_types.py index bee5df4bd115..039b7377c1ab 100644 --- a/weave/weave_types.py +++ b/weave/weave_types.py @@ -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() @@ -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: