Skip to content

Commit

Permalink
chore(weave): add metadata_only to obj_read
Browse files Browse the repository at this point in the history
  • Loading branch information
gtarpenning committed Jan 22, 2025
1 parent 7b2b7e0 commit cfbc20d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
13 changes: 13 additions & 0 deletions tests/trace/test_weave_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,19 @@ def test_object_version_read(client):
assert obj_res.obj.val == {"a": i}
assert obj_res.obj.version_index == i

# read each object one at a time, check the version, metadata only
for i in range(10):
obj_res = client.server.obj_read(
tsi.ObjReadReq(
project_id=client._project_id(),
object_id=refs[i].name,
digest=refs[i].digest,
metadata_only=True,
)
)
assert obj_res.obj.val == {}
assert obj_res.obj.version_index == i

# now grab the latest version of the object
obj_res = client.server.obj_read(
tsi.ObjReadReq(
Expand Down
3 changes: 2 additions & 1 deletion weave/trace_server/clickhouse_trace_server_batched.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,9 @@ def obj_read(self, req: tsi.ObjReadReq) -> tsi.ObjReadRes:
object_query_builder.add_digests_conditions(req.digest)
object_query_builder.add_object_ids_condition([req.object_id])
object_query_builder.set_include_deleted(include_deleted=True)
metadata_only = req.metadata_only or False

objs = self._select_objs_query(object_query_builder)
objs = self._select_objs_query(object_query_builder, metadata_only)
if len(objs) == 0:
raise NotFoundError(f"Obj {req.object_id}:{req.digest} not found")

Expand Down
6 changes: 6 additions & 0 deletions weave/trace_server/trace_server_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ class ObjReadReq(BaseModel):
object_id: str
digest: str

metadata_only: Optional[bool] = Field(
default=False,
description="If true, the `val` column is not read from the database and is empty."
"All other fields are returned.",
)


class ObjReadRes(BaseModel):
obj: ObjSchema
Expand Down

0 comments on commit cfbc20d

Please sign in to comment.