diff --git a/examples/experimental/app/scenario_compare.ipynb b/examples/experimental/app/scenario_compare.ipynb index 4450f818b800..befb14b8f0af 100644 --- a/examples/experimental/app/scenario_compare.ipynb +++ b/examples/experimental/app/scenario_compare.ipynb @@ -95,7 +95,7 @@ "source": [ "# Ugly. We need to compute the Weave type right now.\n", "# TODO: Fix\n", - "from weave import infer_types\n", + "from weave.legacy import infer_types\n", "run_type = weave.types.List(infer_types.python_type_to_type(scenario.ScenarioResult))\n", "\n", "import time\n", diff --git a/weave/legacy/decorator_type.py b/weave/legacy/decorator_type.py index 97b3277d2b89..9568a906f482 100644 --- a/weave/legacy/decorator_type.py +++ b/weave/legacy/decorator_type.py @@ -2,9 +2,9 @@ import inspect import typing -from weave import errors, infer_types +from weave import errors from weave import weave_types as types -from weave.legacy import context_state, decorator_class, object_type_ref_util +from weave.legacy import context_state, decorator_class, object_type_ref_util, infer_types _py_type = type diff --git a/weave/legacy/ecosystem/torchvision/datasets.py b/weave/legacy/ecosystem/torchvision/datasets.py index 424f8d6fa059..46f74273f750 100644 --- a/weave/legacy/ecosystem/torchvision/datasets.py +++ b/weave/legacy/ecosystem/torchvision/datasets.py @@ -11,7 +11,7 @@ from torchvision import datasets import weave -from weave import infer_types +from weave.legacy import infer_types from weave.legacy import panels ExampleType = TypeVar("ExampleType") diff --git a/weave/legacy/ecosystem/wandb/weave_plotly.py b/weave/legacy/ecosystem/wandb/weave_plotly.py index bb6d4e58966c..e5e9e85b9836 100644 --- a/weave/legacy/ecosystem/wandb/weave_plotly.py +++ b/weave/legacy/ecosystem/wandb/weave_plotly.py @@ -9,7 +9,8 @@ from plotly import graph_objs as go import weave -from weave import infer_types, weave_internal +from weave import weave_internal +from weave.legacy import infer_types class PlotlyType(weave.types.Type): diff --git a/weave/infer_types.py b/weave/legacy/infer_types.py similarity index 97% rename from weave/infer_types.py rename to weave/legacy/infer_types.py index a9801677609a..55d9988fb025 100644 --- a/weave/infer_types.py +++ b/weave/legacy/infer_types.py @@ -8,7 +8,7 @@ from weave.legacy import graph -from . import errors, weave_types +from .. import errors, weave_types class TypedDictLike: @@ -19,7 +19,7 @@ def is_typed_dict_like(t: type) -> typing_extensions.TypeGuard[TypedDictLike]: return hasattr(t, "__required_keys__") -def simple_python_type_to_type(py_type: type): +def simple_python_type_to_type(py_type: type): # type: ignore if isinstance(py_type, str): raise errors.WeaveTypeError( "Cannot yet detect Weave type from forward type references" diff --git a/weave/legacy/op_def_type.py b/weave/legacy/op_def_type.py index 4f2553cdc47e..964aeb4cab98 100644 --- a/weave/legacy/op_def_type.py +++ b/weave/legacy/op_def_type.py @@ -11,9 +11,9 @@ from _ast import AsyncFunctionDef, ExceptHandler from typing import Any -from weave import environment, errors, infer_types, registry_mem, storage +from weave import environment, errors, registry_mem, storage from weave import weave_types as types -from weave.legacy import artifact_fs, artifact_local, context_state +from weave.legacy import artifact_fs, artifact_local, context_state, infer_types if typing.TYPE_CHECKING: from .op_def import OpDef diff --git a/weave/pyfunc_type_util.py b/weave/pyfunc_type_util.py index 0fdc94a11cdf..4ae2943cc1ff 100644 --- a/weave/pyfunc_type_util.py +++ b/weave/pyfunc_type_util.py @@ -1,9 +1,9 @@ import inspect import typing -from weave.legacy import op_args +from weave.legacy import infer_types, op_args -from . import errors, infer_types +from . import errors from . import weave_types as types InputTypeItemType = typing.Union[types.Type, typing.Callable[..., types.Type]] diff --git a/weave/tests/legacy/test_infer_types.py b/weave/tests/legacy/test_infer_types.py index e508dad0d493..5ddaf587ed10 100644 --- a/weave/tests/legacy/test_infer_types.py +++ b/weave/tests/legacy/test_infer_types.py @@ -2,7 +2,8 @@ from weave.legacy import graph -from ... import infer_types, weave_types +from ... import weave_types +from ...legacy import infer_types def test_node_with_generic(): diff --git a/weave/tests/legacy/test_typeddict_notrequired.py b/weave/tests/legacy/test_typeddict_notrequired.py index fc10cf75270f..b58c53964f41 100644 --- a/weave/tests/legacy/test_typeddict_notrequired.py +++ b/weave/tests/legacy/test_typeddict_notrequired.py @@ -6,8 +6,8 @@ TypedDict, ) -from weave import infer_types from weave import weave_types as types +from weave.legacy import infer_types class _TestNotRequiredTypedDict(TypedDict): diff --git a/weave/weave_pydantic.py b/weave/weave_pydantic.py index 50e68a407dee..19d200ad2fd1 100644 --- a/weave/weave_pydantic.py +++ b/weave/weave_pydantic.py @@ -1,7 +1,7 @@ from pydantic import BaseModel, create_model -from . import infer_types from . import weave_types as types +from .legacy import infer_types def weave_type_to_pydantic( diff --git a/weave/weave_types.py b/weave/weave_types.py index 9bc82f9039d1..990ec2586a86 100644 --- a/weave/weave_types.py +++ b/weave/weave_types.py @@ -1274,7 +1274,7 @@ def _hashable(self): @classmethod def type_of_instance(cls, obj): - from . import infer_types + from .legacy import infer_types attr_types = {} for field in dataclasses.fields(obj):