Skip to content

Commit

Permalink
move to legacy: infer_types
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtruong committed Aug 27, 2024
1 parent 91bf669 commit 5ad400f
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/experimental/app/scenario_compare.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions weave/legacy/decorator_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion weave/legacy/ecosystem/torchvision/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion weave/legacy/ecosystem/wandb/weave_plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions weave/infer_types.py → weave/legacy/infer_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from weave.legacy import graph

from . import errors, weave_types
from .. import errors, weave_types


class TypedDictLike:
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions weave/legacy/op_def_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions weave/pyfunc_type_util.py
Original file line number Diff line number Diff line change
@@ -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]]
Expand Down
3 changes: 2 additions & 1 deletion weave/tests/legacy/test_infer_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion weave/tests/legacy/test_typeddict_notrequired.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion weave/weave_pydantic.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
2 changes: 1 addition & 1 deletion weave/weave_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 5ad400f

Please sign in to comment.