Skip to content

Commit

Permalink
split: test_weave_api into trace and legacy components
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtruong committed Aug 26, 2024
1 parent 972ef34 commit 9a72ee3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
28 changes: 1 addition & 27 deletions weave/legacy/tests/test_weave_api.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import os

import pytest

import weave
import weave.legacy.weave.context_state
import weave.legacy.weave.wandb_api
import weave.trace.weave_init



def test_create_list_rename_delete():
Expand All @@ -32,25 +28,3 @@ def test_create_list_rename_delete():
weave.legacy.weave.ops.delete_artifact(art_node)
arts = weave.use(weave.legacy.weave.ops.local_artifacts())
assert len(arts) == 0


def test_weave_finish_unsets_client(client):
@weave.op
def foo():
return 1

weave.trace.client_context.weave_client.set_weave_client_global(None)
weave.trace.weave_init._current_inited_client = (
weave.trace.weave_init.InitializedClient(client)
)
weave_client = weave.trace.weave_init._current_inited_client.client
assert weave.trace.weave_init._current_inited_client is not None

foo()
assert len(list(weave_client.calls())) == 1

weave.finish()

foo()
assert len(list(weave_client.calls())) == 1
assert weave.trace.weave_init._current_inited_client is None
24 changes: 24 additions & 0 deletions weave/tests/trace/test_weave_api_trace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import weave
import weave.trace.weave_init


def test_weave_finish_unsets_client(client):
@weave.op
def foo():
return 1

weave.trace.client_context.weave_client.set_weave_client_global(None)
weave.trace.weave_init._current_inited_client = (
weave.trace.weave_init.InitializedClient(client)
)
weave_client = weave.trace.weave_init._current_inited_client.client
assert weave.trace.weave_init._current_inited_client is not None

foo()
assert len(list(weave_client.calls())) == 1

weave.finish()

foo()
assert len(list(weave_client.calls())) == 1
assert weave.trace.weave_init._current_inited_client is None

0 comments on commit 9a72ee3

Please sign in to comment.