Skip to content

Commit

Permalink
Fixed some merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tssweeney committed Dec 21, 2024
1 parent 9359fab commit 22e2867
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ export const createBuiltinObjectInstance = async <
);
}

const reqWithLeafObjectClass: TraceObjCreateReq = {
const reqWithBaseObjectClass: TraceObjCreateReq = {
...req,
obj: {
...req.obj,
builtin_object_class: builtinObjectClassName,
},
};

return client.objCreate(reqWithLeafObjectClass);
return client.objCreate(reqWithBaseObjectClass);
};
11 changes: 11 additions & 0 deletions weave/trace/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ def _load_custom_obj_files(


def from_json(obj: Any, project_id: str, server: TraceServerInterface) -> Any:
from weave.builtin_objects.builtin_registry import get_builtin

if isinstance(obj, list):
return [from_json(v, project_id, server) for v in obj]
elif isinstance(obj, dict):
Expand All @@ -265,6 +267,15 @@ def from_json(obj: Any, project_id: str, server: TraceServerInterface) -> Any:
and (builtin_object_class := BUILTIN_OBJECT_REGISTRY.get(val_type))
):
return builtin_object_class.model_validate(obj)
elif (
isinstance(val_type, str)
and obj.get("_class_name") == val_type
and (baseObject := get_builtin(val_type))
):
valid_keys = baseObject.model_fields.keys()
return baseObject.model_validate(
{k: v for k, v in obj.items() if k in valid_keys}
)
else:
return ObjectRecord(
{k: from_json(v, project_id, server) for k, v in obj.items()}
Expand Down
2 changes: 0 additions & 2 deletions weave/trace/weave_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1560,8 +1560,6 @@ def _ref_is_own(self, ref: Ref) -> bool:
return isinstance(ref, Ref)

def _project_id(self) -> str:
# if self.entity == "":
# return self.project
return f"{self.entity}/{self.project}"

@trace_sentry.global_trace_sentry.watch()
Expand Down
21 changes: 20 additions & 1 deletion weave/trace_server/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,23 @@

---- Decomposition PRs ----
1. Change/Add the set_object_class instead of base_object_class
2. Add new methods to the server
2. Add new methods to the server





Desired Features:
1. Create a model via API
* Again, nested refs are a bit confusing here (ex evals... maybe this is an add on?)
2. Remotely invoke a model via API
3. Fetch a model as runtime object from API
* I may have blown away some work in the earlier merge
* need to validate how recursive reconstruction will work
4. Locally invoke a model constructed via API

---

Scorer APIs:
1. Standardize env variable fetching
2. Standardize provider/client construction

0 comments on commit 22e2867

Please sign in to comment.