diff --git a/weave/__init__.py b/weave/__init__.py index 0ed50283b77b..9ea806d2e21f 100644 --- a/weave/__init__.py +++ b/weave/__init__.py @@ -13,25 +13,21 @@ _loading_builtins_token = _context_state.set_loading_built_ins() from weave.legacy import weave_types as types -from .legacy import storage - -from .legacy.api import * -from .trace.api import * - -from .legacy.errors import * - +from weave.legacy import storage +from weave.legacy.api import * +from weave.legacy.errors import * from weave.legacy import mappers_python_def - from weave.legacy import wandb_api as _wandb_api +from weave.legacy import context as _context -from . import version +from weave import version _wandb_api.init() # Ensure there is a client available for eager mode -from weave.legacy import context as _context +from weave.trace.api import * _context_state.clear_loading_built_ins(_loading_builtins_token) __version__ = version.VERSION diff --git a/weave/api.py b/weave/api.py deleted file mode 100644 index 892dd0ec9687..000000000000 --- a/weave/api.py +++ /dev/null @@ -1,4 +0,0 @@ -"""These are the top-level functions in the `import weave` namespace.""" - -from .legacy.api import * -from .trace.api import * diff --git a/weave/deploy/modal/stub.py b/weave/deploy/modal/stub.py index 2dee6e838e6e..89eeff34bccf 100644 --- a/weave/deploy/modal/stub.py +++ b/weave/deploy/modal/stub.py @@ -26,7 +26,7 @@ @stub.function(image=image, secret=Secret.from_dotenv(__file__)) @asgi_app(label=safe_name(uri.name)) def fastapi_app() -> FastAPI: - from weave import api + from weave.trace import api from weave.trace.serve_fastapi import object_method_app uri_ref = parse_uri(os.environ["MODEL_REF"]) diff --git a/weave/tests/legacy/test_api.py b/weave/tests/legacy/test_api.py index dce30746540c..75111a6fc8c0 100644 --- a/weave/tests/legacy/test_api.py +++ b/weave/tests/legacy/test_api.py @@ -1,6 +1,7 @@ import shutil -from ... import api as weave +from weave.legacy import api as weave + from ...legacy.show import _show_params diff --git a/weave/tests/legacy/test_arrow.py b/weave/tests/legacy/test_arrow.py index 7e8a7703e643..e5554ab165ce 100644 --- a/weave/tests/legacy/test_arrow.py +++ b/weave/tests/legacy/test_arrow.py @@ -7,6 +7,7 @@ import pytest from PIL import Image +from weave.legacy import api as weave from weave.legacy import ( box, context_state, @@ -36,7 +37,6 @@ from weave.legacy.ops_primitives import list_, make_list from weave.tests import list_arrow_test_helpers as lath -from ... import api as weave from ...tests import tag_test_util as ttu from ...tests import weavejs_ops from ...tests.legacy import test_wb diff --git a/weave/tests/legacy/test_arrow_vectorizer.py b/weave/tests/legacy/test_arrow_vectorizer.py index 8f41805c8408..1bb224fdb4f4 100644 --- a/weave/tests/legacy/test_arrow_vectorizer.py +++ b/weave/tests/legacy/test_arrow_vectorizer.py @@ -5,6 +5,7 @@ import pytest from pyarrow import compute as pc +from weave.legacy import api as weave from weave.legacy import box, dispatch, errors, ops, weave_internal from weave.legacy import ops_arrow as arrow from weave.legacy import weave_types as types @@ -18,8 +19,6 @@ from weave.legacy.ops_domain import wb_domain_types as wdt from weave.legacy.ops_primitives import Boolean, Number, date, dict_, list_ -from ... import api as weave - string_ops_test_cases = [ ("eq-scalar", lambda x: x == "bc", [True, False, False]), ("ne-scalar", lambda x: x != "bc", [False, True, True]), diff --git a/weave/tests/legacy/test_async.py b/weave/tests/legacy/test_async.py index 976e7e9398d8..e0a9632154e0 100644 --- a/weave/tests/legacy/test_async.py +++ b/weave/tests/legacy/test_async.py @@ -1,8 +1,6 @@ import pytest -from weave.legacy import async_demo, ops, runs - -from ... import api, storage +from weave.legacy import api, async_demo, ops, runs, storage def test_run_basic(): diff --git a/weave/tests/legacy/test_basic_ops.py b/weave/tests/legacy/test_basic_ops.py index 19c2d3020b8b..e8868da0e03d 100644 --- a/weave/tests/legacy/test_basic_ops.py +++ b/weave/tests/legacy/test_basic_ops.py @@ -1,10 +1,9 @@ +from weave.legacy import api as weave from weave.legacy import box, ops from weave.legacy.ops_primitives import number from weave.legacy.ops_primitives.string import * from weave.legacy.weave_internal import make_const_node -from ... import api as weave - def test_number_ops(): nine = make_const_node(weave.types.Number(), 9) diff --git a/weave/tests/legacy/test_compile.py b/weave/tests/legacy/test_compile.py index 2bdde6920af7..dc5679d769d5 100644 --- a/weave/tests/legacy/test_compile.py +++ b/weave/tests/legacy/test_compile.py @@ -4,14 +4,13 @@ import weave from weave.legacy import async_demo, compile, graph from weave.legacy import weave_types as types +from weave.legacy.api import use from weave.legacy.dispatch import RuntimeOutputNode from weave.legacy.ops_arrow import to_arrow from weave.legacy.ops_arrow.vectorize import raise_on_python_bailout from weave.legacy.wandb_interface.wandb_stream_table import StreamTable from weave.legacy.weave_internal import const, define_fn, make_const_node -from ...api import use - def test_automatic_await_compile(): twelve = async_demo.slowmult(3, 4, 0.01) diff --git a/weave/tests/legacy/test_custom_types.py b/weave/tests/legacy/test_custom_types.py index 5f8940785fa0..f5b15ff28bac 100644 --- a/weave/tests/legacy/test_custom_types.py +++ b/weave/tests/legacy/test_custom_types.py @@ -1,10 +1,10 @@ import pytest from PIL import Image +from weave.legacy import api as weave from weave.legacy import context_state as _context from weave.legacy import ops_arrow -from ... import api as weave from ... import errors from .. import geom diff --git a/weave/tests/legacy/test_decorators.py b/weave/tests/legacy/test_decorators.py index cc1a2e1846ba..7682136833fd 100644 --- a/weave/tests/legacy/test_decorators.py +++ b/weave/tests/legacy/test_decorators.py @@ -1,9 +1,8 @@ +from weave.legacy import api as weave from weave.legacy import storage from weave.legacy import weave_types as types from weave.legacy.decorator_op import op -from ... import api as weave - def test_function_op_name(): @op() diff --git a/weave/tests/legacy/test_derive_op.py b/weave/tests/legacy/test_derive_op.py index 85b866595433..637255a8ca72 100644 --- a/weave/tests/legacy/test_derive_op.py +++ b/weave/tests/legacy/test_derive_op.py @@ -1,4 +1,5 @@ -from ... import api as weave +from weave.legacy import api as weave + from ...legacy import registry_mem diff --git a/weave/tests/legacy/test_examples.py b/weave/tests/legacy/test_examples.py index b9324c781f81..1fc1a60d7733 100644 --- a/weave/tests/legacy/test_examples.py +++ b/weave/tests/legacy/test_examples.py @@ -1,10 +1,9 @@ import math import typing +from weave.legacy import api as weave from weave.legacy import context, context_state -from ... import api as weave - class XOnly(typing.TypedDict): x: float diff --git a/weave/tests/legacy/test_execute.py b/weave/tests/legacy/test_execute.py index a36eec66b6b8..8c77e72a21ed 100644 --- a/weave/tests/legacy/test_execute.py +++ b/weave/tests/legacy/test_execute.py @@ -4,10 +4,9 @@ import pytest import weave -from weave.legacy import environment, execute, ops, weave_internal +from weave.legacy import api, environment, execute, ops, weave_internal from weave.legacy import weave_types as types -from ... import api from . import test_wb execute_test_count_op_run_count = 0 diff --git a/weave/tests/legacy/test_file.py b/weave/tests/legacy/test_file.py index 0fed90136c33..d8561dae6a0c 100644 --- a/weave/tests/legacy/test_file.py +++ b/weave/tests/legacy/test_file.py @@ -1,9 +1,7 @@ import pytest import weave -from weave.legacy import context_state, environment, ops - -from ... import api, errors +from weave.legacy import api, context_state, environment, errors, ops def test_dir(): diff --git a/weave/tests/legacy/test_list_arrow_compat.py b/weave/tests/legacy/test_list_arrow_compat.py index 08287ed6da9c..37680040db3a 100644 --- a/weave/tests/legacy/test_list_arrow_compat.py +++ b/weave/tests/legacy/test_list_arrow_compat.py @@ -3,6 +3,7 @@ import numpy as np import pytest +from weave.legacy import api as weave from weave.legacy import box, ops, weave_internal from weave.legacy import ops_arrow as arrow from weave.legacy import weave_types as types @@ -13,7 +14,6 @@ ) from weave.legacy.ops_primitives import dict_, list_ -from ... import api as weave from ...tests import tag_test_util as ttu from .. import list_arrow_test_helpers as lath diff --git a/weave/tests/legacy/test_media_user.py b/weave/tests/legacy/test_media_user.py index edbceb072171..8bb37deb4f47 100644 --- a/weave/tests/legacy/test_media_user.py +++ b/weave/tests/legacy/test_media_user.py @@ -1,10 +1,9 @@ from PIL import Image +from weave.legacy import api as weave from weave.legacy import context_state from weave.legacy.ops_primitives import geom as media_user -from ... import api as weave - def test_im_with_metadata(): base_im = Image.linear_gradient("L").resize((32, 32)) diff --git a/weave/tests/legacy/test_mutations.py b/weave/tests/legacy/test_mutations.py index a83ff5a02725..453d8af7ec5a 100644 --- a/weave/tests/legacy/test_mutations.py +++ b/weave/tests/legacy/test_mutations.py @@ -1,7 +1,6 @@ +from weave.legacy import api as weave from weave.legacy import ops, storage, weave_internal -from ... import api as weave - def test_autocommit(cereal_csv): csv = ops.local_path(cereal_csv).readcsv() diff --git a/weave/tests/legacy/test_node_ref.py b/weave/tests/legacy/test_node_ref.py index eaacc2c31909..0a8d56f1e7e0 100644 --- a/weave/tests/legacy/test_node_ref.py +++ b/weave/tests/legacy/test_node_ref.py @@ -1,6 +1,6 @@ +from weave.legacy import api as weave from weave.legacy import graph -from ... import api as weave from ...legacy import node_ref diff --git a/weave/tests/legacy/test_op_def.py b/weave/tests/legacy/test_op_def.py index aa24f1852824..cb05fe0135c4 100644 --- a/weave/tests/legacy/test_op_def.py +++ b/weave/tests/legacy/test_op_def.py @@ -5,10 +5,9 @@ import pytest +from weave.legacy import api as weave from weave.legacy import context_state -from ... import api as weave - _loading_builtins_token = context_state.set_loading_built_ins() diff --git a/weave/tests/legacy/test_partial_object.py b/weave/tests/legacy/test_partial_object.py index 8096e6061b5e..22eac741e3bb 100644 --- a/weave/tests/legacy/test_partial_object.py +++ b/weave/tests/legacy/test_partial_object.py @@ -1,3 +1,4 @@ +from weave.legacy import api as weave from weave.legacy import compile, ops from weave.legacy import weave_types as types from weave.legacy.language_features.tagging.tagged_value_type import TaggedValueType @@ -5,7 +6,6 @@ from weave.legacy.ops_domain.project_ops import root_all_projects from weave.legacy.ops_domain.report_ops import root_all_reports -from ... import api as weave from .test_wb import table_mock1_no_display_name diff --git a/weave/tests/legacy/test_run_segment.py b/weave/tests/legacy/test_run_segment.py index 6ab3815c2008..fd92b66c5528 100644 --- a/weave/tests/legacy/test_run_segment.py +++ b/weave/tests/legacy/test_run_segment.py @@ -6,13 +6,11 @@ import pytest import weave -from weave.legacy import ops, storage, weave_internal +from weave.legacy import api, ops, storage, weave_internal from weave.legacy import weave_types as types from weave.legacy.ops_arrow import ArrowWeaveList, arrow_as_array from weave.legacy.ops_domain.run_segment import RunSegment -from ... import api - N_NUMERIC_METRICS = 99 # number of numerical columns in the metrics table diff --git a/weave/tests/legacy/test_storage.py b/weave/tests/legacy/test_storage.py index ab91835e742b..29dda1e8963d 100644 --- a/weave/tests/legacy/test_storage.py +++ b/weave/tests/legacy/test_storage.py @@ -7,6 +7,7 @@ import pytest import wandb +from weave.legacy import api as weave from weave.legacy import ( artifact_mem, artifact_wandb, @@ -18,7 +19,6 @@ from weave.legacy.arrow import list_ as arrow from weave.legacy.weave_internal import make_const_node -from ... import api as weave from ...legacy.weavejs_fixes import recursively_unwrap_unions from . import test_helpers diff --git a/weave/tests/legacy/test_table_ops.py b/weave/tests/legacy/test_table_ops.py index c5ece54c3ab1..46f4af2e4362 100644 --- a/weave/tests/legacy/test_table_ops.py +++ b/weave/tests/legacy/test_table_ops.py @@ -3,6 +3,7 @@ import pytest +from weave.legacy import api as weave from weave.legacy import ( box, context, @@ -15,7 +16,6 @@ from weave.legacy import weave_types as types from weave.legacy.ops_domain import table as table_ops -from ... import api as weave from .. import weavejs_ops TABLE_TYPES = ["list", "pandas", "sql"] diff --git a/weave/tests/legacy/test_trace.py b/weave/tests/legacy/test_trace.py index 629ca15a4c34..a0c308aab12c 100644 --- a/weave/tests/legacy/test_trace.py +++ b/weave/tests/legacy/test_trace.py @@ -1,9 +1,9 @@ import re +from weave.legacy import api as weave from weave.legacy import graph, storage from weave.legacy.weave_internal import make_const_node -from ... import api as weave from ...legacy import trace_legacy diff --git a/weave/tests/legacy/test_wb_domain_types.py b/weave/tests/legacy/test_wb_domain_types.py index b035ebd3b7ac..ed550677062e 100644 --- a/weave/tests/legacy/test_wb_domain_types.py +++ b/weave/tests/legacy/test_wb_domain_types.py @@ -1,9 +1,8 @@ +from weave.legacy import api as weave from weave.legacy import storage from weave.legacy import weave_types as types from weave.legacy.ops_domain import wb_domain_types as wdt -from ... import api as weave - def test_with_keys_assignability(): org_type = wdt.OrgType diff --git a/weave/tests/legacy/test_weavejs_fixes.py b/weave/tests/legacy/test_weavejs_fixes.py index c40a9d3145f3..94bc36039a85 100644 --- a/weave/tests/legacy/test_weavejs_fixes.py +++ b/weave/tests/legacy/test_weavejs_fixes.py @@ -3,6 +3,7 @@ import pytest from weave.legacy import ( + api, context_state, mappers_python, ops, @@ -11,8 +12,6 @@ ) from weave.legacy import weave_types as types -from ... import api - @pytest.mark.skip( "calling custom ops with graph engine is broken right now. Not needed for weaveflow" diff --git a/weave/tests/list_arrow_test_helpers.py b/weave/tests/list_arrow_test_helpers.py index 8c2fedcd4a98..ab7e19d8eb18 100644 --- a/weave/tests/list_arrow_test_helpers.py +++ b/weave/tests/list_arrow_test_helpers.py @@ -1,8 +1,7 @@ +from weave.legacy import api as weave from weave.legacy import ops_arrow as arrow from weave.legacy.ops_primitives import list_ -from .. import api as weave - class ListLikeNodeInterface: @staticmethod diff --git a/weave/tests/trace/test_server.py b/weave/tests/trace/test_server.py index aaaf1f08ff74..936eb7aa3601 100644 --- a/weave/tests/trace/test_server.py +++ b/weave/tests/trace/test_server.py @@ -6,7 +6,7 @@ import pytest import requests -from weave import api as weave +from weave.legacy import api as weave from weave.legacy import client as _client from weave.legacy import context_state, ops from weave.legacy import server as _server diff --git a/weave/trace/cli.py b/weave/trace/cli.py index 59a6118d12c1..2204e2c4c76c 100644 --- a/weave/trace/cli.py +++ b/weave/trace/cli.py @@ -5,10 +5,9 @@ from weave import __version__ from weave.deploy import gcp as google +from weave.trace import api from weave.trace.refs import ObjectRef, parse_uri -from . import api - # from .model_server import app # TODO: does this work?