Skip to content

Commit

Permalink
trace_server_interface
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtruong committed Oct 8, 2024
1 parent 6bf8642 commit de850fe
Show file tree
Hide file tree
Showing 37 changed files with 43 additions and 40 deletions.
4 changes: 2 additions & 2 deletions docs/scripts/generate_python_sdk_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ def main():
from weave.trace import feedback, util
from weave.trace import op as OpSpec
from weave.trace import weave_client as client
from weave.trace_server import (
from weave.trace_server.interface import query
from weave.trace_server_common import (
trace_server_interface,
)
from weave.trace_server.interface import query

module_root_path = weave.__file__.split("/weave/__init__.py")[0]
for module in [
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
sqlite_trace_server,
)
from weave.trace_server import environment as ts_env
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server_bindings import remote_http_trace_server
from weave.trace_server_common import trace_server_interface as tsi

# Force testing to never report wandb sentry events
os.environ["WANDB_ERROR_REPORTING"] = "false"
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/dspy/dspy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
flattened_calls_to_names,
)
from weave.trace.weave_client import WeaveClient
from weave.trace_server.trace_server_interface import CallsFilter
from weave.trace_server_common.trace_server_interface import CallsFilter


@pytest.mark.skip_clickhouse_client
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/groq/groq_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
flatten_calls,
flattened_calls_to_names,
)
from weave.trace_server.trace_server_interface import CallsFilter
from weave.trace_server_common.trace_server_interface import CallsFilter


@pytest.mark.skip_clickhouse_client # TODO:VCR recording does not seem to allow us to make requests to the clickhouse db in non-recording mode
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/langchain/langchain_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
op_name_from_ref,
)
from weave.trace.weave_client import Call, WeaveClient
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server_common import trace_server_interface as tsi


@pytest.fixture(scope="session", autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/llamaindex/llamaindex_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
flattened_calls_to_names,
)
from weave.trace.weave_client import Call
from weave.trace_server.trace_server_interface import CallsFilter
from weave.trace_server_common.trace_server_interface import CallsFilter


def assert_calls_correct_for_quickstart(flattened_calls: list[Call]) -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_anonymous_ops.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from weave.trace import weave_client
from weave.trace_server.trace_server_interface import CallsQueryReq
from weave.trace_server_common.trace_server_interface import CallsQueryReq


def test_named_op(client: weave_client.WeaveClient) -> str:
Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_client_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pytest

from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.errors import InvalidRequest
from weave.trace_server.interface.query import Query
from weave.trace_server.sqlite_trace_server import SqliteTraceServer
from weave.trace_server_common import trace_server_interface as tsi


def test_cost_apis(client):
Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_client_feedback.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.errors import InvalidRequest
from weave.trace_server.interface.query import Query
from weave.trace_server_common import trace_server_interface as tsi


def test_feedback_apis(client):
Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_client_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from weave.trace import weave_client
from weave.trace.vals import MissingSelfInstanceError
from weave.trace.weave_client import sanitize_object_name
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.clickhouse_trace_server_batched import ENTITY_TOO_LARGE_PAYLOAD
from weave.trace_server.ids import generate_id
from weave.trace_server.refs_internal import extra_value_quoter
Expand All @@ -36,6 +35,7 @@
extract_refs_from_values,
)
from weave.trace_server.validation import SHOULD_ENFORCE_OBJ_ID_CHARSET
from weave.trace_server_common import trace_server_interface as tsi

## Hacky interface compatibility helpers

Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_evaluation_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from tests.trace.util import DummyTestException
from weave.trace.context import raise_on_captured_errors
from weave.trace.weave_client import WeaveClient
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server_common import trace_server_interface as tsi


class BlockingTraceServer(tsi.TraceServerInterface):
Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_evaluations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import weave
from tests.trace.util import AnyIntMatcher
from weave import Evaluation, Model
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server_common import trace_server_interface as tsi


def flatten_calls(
Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_objs_query.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import weave
from weave.trace.weave_client import WeaveClient
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server_common import trace_server_interface as tsi


def generate_objects(weave_client: WeaveClient, obj_count: int, version_count: int):
Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_op_argument_forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

import weave
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server_common import trace_server_interface as tsi

# This file tests the different argument variations that can be passed to an op.
#
Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_op_return_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import weave
from weave.trace.op_extensions.accumulator import add_accumulator
from weave.trace.weave_client import get_ref
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server_common import trace_server_interface as tsi


def test_op_return_sync_empty(client):
Expand Down
5 changes: 4 additions & 1 deletion tests/trace/test_op_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import pytest

import weave
from weave.trace_server.trace_server_interface import FileContentReadReq, ObjReadReq
from weave.trace_server_common.trace_server_interface import (
FileContentReadReq,
ObjReadReq,
)


def get_saved_code(client, ref):
Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_table_query.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import random

from weave.trace.weave_client import WeaveClient
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server_common import trace_server_interface as tsi


def generate_table_data(client: WeaveClient, n_rows: int, n_cols: int):
Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_trace_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from weave.trace_server import trace_server_interface as tsi
from weave.trace_server_common import trace_server_interface as tsi


def test_save_object(client):
Expand Down
4 changes: 2 additions & 2 deletions tests/trace/test_weave_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import requests

import weave
import weave.trace_server.trace_server_interface as tsi
import weave.trace_server_common.trace_server_interface as tsi
from tests.trace.testutil import ObjectRefStrMatcher
from tests.trace.util import (
AnyIntMatcher,
Expand All @@ -34,7 +34,7 @@
from weave.trace_server.sqlite_trace_server import (
SqliteTraceServer,
)
from weave.trace_server.trace_server_interface import (
from weave.trace_server_common.trace_server_interface import (
FileContentReadReq,
FileCreateReq,
RefsReadBatchReq,
Expand Down
2 changes: 1 addition & 1 deletion tests/trace_server/test_call_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import uuid

from weave.trace import weave_client
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server_common import trace_server_interface as tsi


def test_call_update_out_of_order(client: weave_client.WeaveClient):
Expand Down
2 changes: 1 addition & 1 deletion tests/trace_server/test_calls_query_builder.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import sqlparse

from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.calls_query_builder import CallsQuery, HardCodedFilter
from weave.trace_server.interface import query as tsi_query
from weave.trace_server.orm import ParamBuilder
from weave.trace_server_common import trace_server_interface as tsi


def test_query_baseline() -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/trace_server/test_orm.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import pytest

from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.orm import (
Column,
ParamBuilder,
Table,
_transform_external_field_to_internal_field,
combine_conditions,
)
from weave.trace_server_common import trace_server_interface as tsi


def test_parambuilder_clickhouse():
Expand Down
2 changes: 1 addition & 1 deletion tests/trace_server/test_remote_http_trace_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import requests
from pydantic import ValidationError

from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.ids import generate_id
from weave.trace_server_bindings.remote_http_trace_server import RemoteHTTPTraceServer
from weave.trace_server_common import trace_server_interface as tsi


def generate_start(id) -> tsi.StartedCallSchemaForInsert:
Expand Down
2 changes: 1 addition & 1 deletion weave/trace/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from weave.trace.rich import pydantic_util
from weave.trace.rich.container import AbstractRichContainer
from weave.trace.rich.refs import Refs
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.interface.query import Query
from weave.trace_server_common import trace_server_interface as tsi


class Feedbacks(AbstractRichContainer[tsi.Feedback]):
Expand Down
4 changes: 2 additions & 2 deletions weave/trace/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from weave.trace import custom_objs
from weave.trace.object_record import ObjectRecord
from weave.trace.refs import ObjectRef, TableRef, parse_uri
from weave.trace_server.trace_server_interface import (
from weave.trace_server.trace_server_interface_util import bytes_digest
from weave.trace_server_common.trace_server_interface import (
FileContentReadReq,
FileCreateReq,
TraceServerInterface,
)
from weave.trace_server.trace_server_interface_util import bytes_digest

if typing.TYPE_CHECKING:
from weave.trace.weave_client import WeaveClient
Expand Down
2 changes: 1 addition & 1 deletion weave/trace/vals.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)
from weave.trace.serialize import from_json
from weave.trace.table import Table
from weave.trace_server.trace_server_interface import (
from weave.trace_server_common.trace_server_interface import (
ObjReadReq,
TableQueryReq,
TableRowFilter,
Expand Down
4 changes: 2 additions & 2 deletions weave/trace/weave_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
from weave.trace.util import deprecated
from weave.trace.vals import WeaveObject, WeaveTable, make_trace_obj
from weave.trace_server.ids import generate_id
from weave.trace_server.trace_server_interface import (
from weave.trace_server_bindings.remote_http_trace_server import RemoteHTTPTraceServer
from weave.trace_server_common.trace_server_interface import (
CallEndReq,
CallSchema,
CallsDeleteReq,
Expand Down Expand Up @@ -64,7 +65,6 @@
TableSchemaForInsert,
TraceServerInterface,
)
from weave.trace_server_bindings.remote_http_trace_server import RemoteHTTPTraceServer

# Controls if objects can have refs to projects not the WeaveClient project.
# If False, object refs with with mismatching projects will be recreated.
Expand Down
2 changes: 1 addition & 1 deletion weave/trace_server/calls_query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import sqlparse
from pydantic import BaseModel, Field

from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.errors import InvalidFieldError
from weave.trace_server.interface import query as tsi_query
from weave.trace_server.orm import (
Expand All @@ -47,6 +46,7 @@
from weave.trace_server.trace_server_interface_util import (
WILDCARD_ARTIFACT_VERSION_AND_PATH,
)
from weave.trace_server_common import trace_server_interface as tsi

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion weave/trace_server/clickhouse_trace_server_batched.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
from weave.trace_server import clickhouse_trace_server_migrator as wf_migrator
from weave.trace_server import environment as wf_env
from weave.trace_server import refs_internal as ri
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.calls_query_builder import (
CallsQuery,
HardCodedFilter,
Expand Down Expand Up @@ -106,6 +105,7 @@
extract_refs_from_values,
str_digest,
)
from weave.trace_server_common import trace_server_interface as tsi

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import typing
from typing import Callable, Iterator, TypeVar

from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.trace_server_converter import (
universal_ext_to_int_ref_converter,
universal_int_to_ext_ref_converter,
)
from weave.trace_server_common import trace_server_interface as tsi


class IdConverter:
Expand Down
2 changes: 1 addition & 1 deletion weave/trace_server/feedback.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from pydantic import BaseModel, ValidationError

from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.errors import InvalidRequest
from weave.trace_server.orm import Column, Table
from weave.trace_server.validation import (
validate_purge_req_multiple,
validate_purge_req_one,
)
from weave.trace_server_common import trace_server_interface as tsi

TABLE_FEEDBACK = Table(
"feedback",
Expand Down
2 changes: 1 addition & 1 deletion weave/trace_server/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from pydantic import BaseModel
from typing_extensions import TypeAlias

from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.interface import query as tsi_query
from weave.trace_server_common import trace_server_interface as tsi

DatabaseType = typing.Literal["clickhouse", "sqlite"]

Expand Down
2 changes: 1 addition & 1 deletion weave/trace_server/sqlite_trace_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import emoji

from weave.trace_server import refs_internal as ri
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.emoji_util import detone_emojis
from weave.trace_server.errors import InvalidRequest
from weave.trace_server.feedback import (
Expand Down Expand Up @@ -40,6 +39,7 @@
str_digest,
)
from weave.trace_server.validation import object_id_validator
from weave.trace_server_common import trace_server_interface as tsi

MAX_FLUSH_COUNT = 10000
MAX_FLUSH_AGE = 15
Expand Down
2 changes: 1 addition & 1 deletion weave/trace_server/token_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import re
from datetime import datetime

from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.clickhouse_schema import SelectableCHCallSchema
from weave.trace_server.errors import InvalidRequest
from weave.trace_server.orm import (
Expand All @@ -16,6 +15,7 @@
validate_purge_req_multiple,
validate_purge_req_one,
)
from weave.trace_server_common import trace_server_interface as tsi

DUMMY_LLM_ID = "weave_dummy_llm_id"
DUMMY_LLM_USAGE = (
Expand Down
Loading

0 comments on commit de850fe

Please sign in to comment.