Skip to content

Commit

Permalink
change to big change to builtin
Browse files Browse the repository at this point in the history
  • Loading branch information
tssweeney committed Dec 13, 2024
1 parent c72cfae commit 2bfdd96
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 29 deletions.
10 changes: 5 additions & 5 deletions dev_docs/BaseObjectClasses.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ While many Weave Objects are free-form and user-defined, there is often a need f

Here's how to define and use a validated base object:

1. **Define your schema** (in `weave/trace_server/interface/base_object_classes/your_schema.py`):
1. **Define your schema** (in `weave/trace_server/interface/builtin_object_classes/your_schema.py`):

```python
from pydantic import BaseModel
from weave.trace_server.interface.base_object_classes import base_object_def
from weave.trace_server.interface.builtin_object_classes import base_object_def

class NestedConfig(BaseModel):
setting_a: int
Expand Down Expand Up @@ -154,10 +154,10 @@ Run `make synchronize-base-object-schemas` to ensure the frontend TypeScript typ

### Architecture Flow

1. Define your schema in a python file in the `weave/trace_server/interface/base_object_classes/test_only_example.py` directory. See `weave/trace_server/interface/base_object_classes/test_only_example.py` as an example.
2. Make sure to register your schemas in `weave/trace_server/interface/base_object_classes/builtin_object_registry.py` by calling `register_base_object`.
1. Define your schema in a python file in the `weave/trace_server/interface/builtin_object_classes/test_only_example.py` directory. See `weave/trace_server/interface/builtin_object_classes/test_only_example.py` as an example.
2. Make sure to register your schemas in `weave/trace_server/interface/builtin_object_classes/builtin_object_registry.py` by calling `register_base_object`.
3. Run `make synchronize-base-object-schemas` to generate the frontend types.
* The first step (`make generate_base_object_schemas`) will run `weave/scripts/generate_base_object_schemas.py` to generate a JSON schema in `weave/trace_server/interface/base_object_classes/generated/generated_base_object_class_schemas.json`.
* The first step (`make generate_base_object_schemas`) will run `weave/scripts/generate_base_object_schemas.py` to generate a JSON schema in `weave/trace_server/interface/builtin_object_classes/generated/generated_base_object_class_schemas.json`.
* The second step (yarn `generate-schemas`) will read this file and use it to generate the frontend types located in `weave-js/src/components/PagePanelComponents/Home/Browse3/pages/wfReactInterface/generatedBaseObjectClasses.zod.ts`.
4. Now, each use case uses different parts:
1. `Python Writing`. Users can directly import these classes and use them as normal Pydantic models, which get published with `weave.publish`. The python client correct builds the requisite payload.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)
from tests.trace.util import client_is_sqlite
from weave.trace.weave_client import WeaveClient
from weave.trace_server.interface.base_object_classes.actions import (
from weave.trace_server.interface.builtin_object_classes.actions import (
ActionSpec,
)
from weave.trace_server.trace_server_interface import (
Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_actions_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import weave
from tests.trace.util import client_is_sqlite
from weave.trace.weave_client import WeaveClient
from weave.trace_server.interface.base_object_classes.actions import (
from weave.trace_server.interface.builtin_object_classes.actions import (
ActionSpec,
)
from weave.trace_server.trace_server_interface import (
Expand Down
2 changes: 1 addition & 1 deletion tests/trace/test_base_object_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from weave.trace.refs import ObjectRef
from weave.trace.weave_client import WeaveClient
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.interface.base_object_classes.test_only_example import (
from weave.trace_server.interface.builtin_object_classes.test_only_example import (
TestOnlyNestedBaseModel,
)

Expand Down
2 changes: 1 addition & 1 deletion weave-js/scripts/generate-schemas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Exit on error
set -e

SCHEMA_INPUT_PATH="../weave/trace_server/interface/base_object_classes/generated/generated_base_object_class_schemas.json"
SCHEMA_INPUT_PATH="../weave/trace_server/interface/builtin_object_classes/generated/generated_base_object_class_schemas.json"
SCHEMA_OUTPUT_PATH="./src/components/PagePanelComponents/Home/Browse3/pages/wfReactInterface/generatedBaseObjectClasses.zod.ts"

echo "Generating schemas..."
Expand Down
2 changes: 1 addition & 1 deletion weave/flow/annotation_spec.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from weave.trace_server.interface.base_object_classes import annotation_spec
from weave.trace_server.interface.builtin_object_classes import annotation_spec

# Re-export:
AnnotationSpec = annotation_spec.AnnotationSpec
2 changes: 1 addition & 1 deletion weave/flow/leaderboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from weave.trace.refs import OpRef
from weave.trace.weave_client import WeaveClient, get_ref
from weave.trace_server.interface.base_object_classes import leaderboard
from weave.trace_server.interface.builtin_object_classes import leaderboard
from weave.trace_server.trace_server_interface import CallsFilter


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

from pydantic import create_model

from weave.trace_server.interface.base_object_classes.builtin_object_registry import (
from weave.trace_server.interface.builtin_object_classes.builtin_object_registry import (
BUILTIN_OBJECT_REGISTRY,
)

Expand Down
2 changes: 1 addition & 1 deletion weave/trace/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
should_disable_weave,
)
from weave.trace.table import Table
from weave.trace_server.interface.base_object_classes import leaderboard
from weave.trace_server.interface.builtin_object_classes import leaderboard


def init(
Expand Down
2 changes: 1 addition & 1 deletion weave/trace/base_objects.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from weave.trace_server.interface.base_object_classes.builtin_object_registry import *
from weave.trace_server.interface.builtin_object_classes.builtin_object_registry import *
2 changes: 1 addition & 1 deletion weave/trace/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from weave.trace.object_record import ObjectRecord
from weave.trace.refs import ObjectRef, TableRef, parse_uri
from weave.trace.sanitize import REDACT_KEYS, REDACTED_VALUE
from weave.trace_server.interface.base_object_classes.builtin_object_registry import (
from weave.trace_server.interface.builtin_object_classes.builtin_object_registry import (
BUILTIN_OBJECT_REGISTRY,
)
from weave.trace_server.trace_server_interface import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from typing import Any

from weave.trace_server.interface.base_object_classes.actions import (
from weave.trace_server.interface.builtin_object_classes.actions import (
ContainsWordsActionConfig,
)
from weave.trace_server.trace_server_interface import (
Expand Down
2 changes: 1 addition & 1 deletion weave/trace_server/actions_worker/actions/llm_judge.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from typing import Any

from weave.trace_server.interface.base_object_classes.actions import (
from weave.trace_server.interface.builtin_object_classes.actions import (
LlmJudgeActionConfig,
)
from weave.trace_server.trace_server_interface import (
Expand Down
2 changes: 1 addition & 1 deletion weave/trace_server/actions_worker/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
do_contains_words_action,
)
from weave.trace_server.actions_worker.actions.llm_judge import do_llm_judge_action
from weave.trace_server.interface.base_object_classes.actions import (
from weave.trace_server.interface.builtin_object_classes.actions import (
ActionConfigType,
ActionSpec,
ContainsWordsActionConfig,
Expand Down
2 changes: 1 addition & 1 deletion weave/trace_server/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from weave.trace_server import refs_internal as ri
from weave.trace_server import trace_server_interface as tsi
from weave.trace_server.errors import InvalidRequest
from weave.trace_server.interface.base_object_classes.annotation_spec import (
from weave.trace_server.interface.builtin_object_classes.annotation_spec import (
AnnotationSpec,
)
from weave.trace_server.interface.feedback_types import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import jsonschema
from pydantic import BaseModel, Field, field_validator

from weave.trace_server.interface.base_object_classes import base_object_def
from weave.trace_server.interface.builtin_object_classes import base_object_def


class LlmJudgeActionConfig(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pydantic import BaseModel, Field, create_model, field_validator, model_validator
from pydantic.fields import FieldInfo

from weave.trace_server.interface.base_object_classes import base_object_def
from weave.trace_server.interface.builtin_object_classes import base_object_def

SUPPORTED_PRIMITIVES = (int, float, bool, str)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from weave.trace_server.interface.base_object_classes.actions import ActionSpec
from weave.trace_server.interface.base_object_classes.annotation_spec import (
from weave.trace_server.interface.builtin_object_classes.actions import ActionSpec
from weave.trace_server.interface.builtin_object_classes.annotation_spec import (
AnnotationSpec,
)
from weave.trace_server.interface.base_object_classes.base_object_def import BaseObject
from weave.trace_server.interface.base_object_classes.leaderboard import Leaderboard
from weave.trace_server.interface.base_object_classes.test_only_example import (
from weave.trace_server.interface.builtin_object_classes.base_object_def import (
BaseObject,
)
from weave.trace_server.interface.builtin_object_classes.leaderboard import Leaderboard
from weave.trace_server.interface.builtin_object_classes.test_only_example import (
TestOnlyExample,
TestOnlyNestedBaseObject,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pydantic import BaseModel

from weave.trace_server.interface.base_object_classes import base_object_def
from weave.trace_server.interface.builtin_object_classes import base_object_def


class LeaderboardColumn(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel

from weave.trace_server.interface.base_object_classes import base_object_def
from weave.trace_server.interface.builtin_object_classes import base_object_def


class TestOnlyNestedBaseModel(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion weave/trace_server/object_class_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pydantic import BaseModel

from weave.trace_server.interface.base_object_classes.builtin_object_registry import (
from weave.trace_server.interface.builtin_object_classes.builtin_object_registry import (
BUILTIN_OBJECT_REGISTRY,
)

Expand Down

0 comments on commit 2bfdd96

Please sign in to comment.