Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtruong committed Jan 22, 2025
1 parent 0705267 commit 2775667
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
24 changes: 23 additions & 1 deletion docs/docs/guides/tracking/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Weave's serialization layer saves and versions objects.
<Tabs groupId="programming-language" queryString>
<TabItem value="python" label="Python" default>

To save an object, call `weave.publish` with the object and a name.

```python
import weave
# Initialize tracking to the project 'intro-example'
Expand All @@ -18,6 +20,17 @@ Weave's serialization layer saves and versions objects.
weave.publish(['felix', 'jimbo', 'billie'], 'cat-names')
```

For builtin weave objects, you can also save in an object-oriented way:

```python
import weave

weave.init('intro-example')

ds = weave.Dataset(rows=[{'x': 1, 'y': 2}, {'x': 3, 'y': 4}])
ds.save('my-dataset')
```

</TabItem>
<TabItem value="typescript" label="TypeScript">
Publishing in TypeScript is still early, so not all objects are fully supported yet.
Expand Down Expand Up @@ -62,7 +75,16 @@ Saving an object with a name will create the first version of that object if it

<Tabs groupId="programming-language" queryString>
<TabItem value="python" label="Python" default>
To delete a version of an object, call `.delete()` on the object ref.

To delete a version of an object, call `.delete()` on the object :

```python
weave.init('intro-example')
cat_names = weave.ref('cat-names:v1').get()
cat_names.delete()
```

You can also delete directly via the ref:

```python
weave.init('intro-example')
Expand Down
10 changes: 4 additions & 6 deletions weave/trace/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import threading
import time
from collections.abc import Iterator
from typing import TYPE_CHECKING, Any
from typing import Any

# TODO: type_handlers is imported here to trigger registration of the image serializer.
# There is probably a better place for this, but including here for now to get the fix in.
Expand All @@ -28,9 +28,6 @@
from weave.trace.table import Table
from weave.trace_server.interface.builtin_object_classes import leaderboard

if TYPE_CHECKING:
from weave.flow.obj import Object

_global_postprocess_inputs: PostprocessInputsFunc | None = None
_global_postprocess_output: PostprocessOutputFunc | None = None

Expand Down Expand Up @@ -180,11 +177,11 @@ def _publish(obj: Any, name: str | None = None) -> weave_client.ObjectRef:
return ref


def delete(obj: Object | ObjectRef) -> None:
def delete(obj: Any) -> None:
import weave

if not isinstance(obj, (weave.Object, weave.ObjectRef)):
raise ValueError("Expected an Object or ObjectRef") # noqa: TRY004
raise TypeError("Expected an Object or ObjectRef")

obj.delete()

Expand Down Expand Up @@ -337,4 +334,5 @@ def finish() -> None:
"get_current_call",
"weave_client_context",
"require_current_call",
"delete",
]

0 comments on commit 2775667

Please sign in to comment.