Skip to content

Commit

Permalink
delete: api; split out trace and query api from single api file
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtruong committed Aug 27, 2024
1 parent 33be551 commit eee78ed
Show file tree
Hide file tree
Showing 30 changed files with 36 additions and 61 deletions.
16 changes: 6 additions & 10 deletions weave/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions weave/api.py

This file was deleted.

2 changes: 1 addition & 1 deletion weave/deploy/modal/stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
3 changes: 2 additions & 1 deletion weave/tests/legacy/test_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import shutil

from ... import api as weave
from weave.legacy import api as weave

from ...legacy.show import _show_params


Expand Down
2 changes: 1 addition & 1 deletion weave/tests/legacy/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest
from PIL import Image

from weave.legacy import api as weave
from weave.legacy import (
box,
context_state,
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_arrow_vectorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]),
Expand Down
4 changes: 1 addition & 3 deletions weave/tests/legacy/test_async.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_basic_ops.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion weave/tests/legacy/test_custom_types.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_decorators.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
3 changes: 2 additions & 1 deletion weave/tests/legacy/test_derive_op.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ... import api as weave
from weave.legacy import api as weave

from ...legacy import registry_mem


Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_examples.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions weave/tests/legacy/test_file.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
2 changes: 1 addition & 1 deletion weave/tests/legacy/test_list_arrow_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_media_user.py
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_mutations.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 1 addition & 1 deletion weave/tests/legacy/test_node_ref.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_op_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
2 changes: 1 addition & 1 deletion weave/tests/legacy/test_partial_object.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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
from weave.legacy.ops_domain import wb_domain_types as wdt
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


Expand Down
4 changes: 1 addition & 3 deletions weave/tests/legacy/test_run_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion weave/tests/legacy/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest
import wandb

from weave.legacy import api as weave
from weave.legacy import (
artifact_mem,
artifact_wandb,
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion weave/tests/legacy/test_table_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest

from weave.legacy import api as weave
from weave.legacy import (
box,
context,
Expand All @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion weave/tests/legacy/test_trace.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_wb_domain_types.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions weave/tests/legacy/test_weavejs_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from weave.legacy import (
api,
context_state,
mappers_python,
ops,
Expand All @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions weave/tests/list_arrow_test_helpers.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion weave/tests/trace/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions weave/trace/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit eee78ed

Please sign in to comment.