-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into tim/huggingface_datasets
- Loading branch information
Showing
11 changed files
with
226 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from tempfile import NamedTemporaryFile | ||
|
||
from weave.initialization import pil_image_thread_safety | ||
|
||
|
||
def test_patching_import_order(): | ||
# This test verifies the correct behavior if patching occurs after the construction | ||
# of an image | ||
assert pil_image_thread_safety._patched | ||
pil_image_thread_safety.undo_threadsafe_patch_to_pil_image() | ||
assert not pil_image_thread_safety._patched | ||
import PIL | ||
|
||
image = PIL.Image.new("RGB", (10, 10)) | ||
with NamedTemporaryFile(suffix=".png") as f: | ||
image.save(f.name) | ||
image = PIL.Image.open(f.name) | ||
|
||
pil_image_thread_safety.apply_threadsafe_patch_to_pil_image() | ||
assert pil_image_thread_safety._patched | ||
|
||
image.crop((0, 0, 10, 10)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# /// script | ||
# requires-python = ">=3.9" | ||
# dependencies = [ | ||
# "weave @ git+https://github.com/wandb/weave.git@master", | ||
# ] | ||
# /// | ||
|
||
# Run this script with `uv run prerelease_dry_run.py` | ||
|
||
import datetime | ||
|
||
import weave | ||
|
||
# This uniq id ensures that the op is not cached | ||
uniq_id = datetime.datetime.now().timestamp() | ||
|
||
|
||
@weave.op | ||
def func(a: int) -> float: | ||
return a + uniq_id | ||
|
||
|
||
def main() -> None: | ||
client = weave.init("test-project") | ||
res = func(42) | ||
|
||
client._flush() | ||
calls = func.calls() | ||
|
||
assert len(calls) == 1 | ||
assert calls[0].output == res | ||
assert calls[0].inputs == {"a": 42} | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
print("Dry run passed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,4 +44,4 @@ | |
""" | ||
|
||
VERSION = "0.51.30-dev0" | ||
VERSION = "0.51.31-dev0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import pytest | ||
from weave_query import ( | ||
weave_types as types, | ||
graph, | ||
op_def, | ||
op_args | ||
) | ||
from weave_query.language_features.tagging import ( | ||
tagged_value_type, | ||
) | ||
from weave_query.propagate_gql_keys import _propagate_gql_keys_for_node | ||
from weave_query.ops_domain import wb_domain_types as wdt | ||
|
||
def test_mapped_tag_propagation(): | ||
test_op = op_def.OpDef( | ||
name="run-base_op", | ||
input_type=op_args.OpNamedArgs({"run": wdt.RunType}), | ||
output_type=types.List(types.Number()), | ||
resolve_fn=lambda: None | ||
) | ||
|
||
mapped_opdef = op_def.OpDef( | ||
name="mapped_run-base_op", | ||
input_type=op_args.OpNamedArgs({"run": types.List(wdt.RunType)}), | ||
output_type=types.List(types.List(types.Number())), | ||
resolve_fn=lambda: None | ||
) | ||
|
||
mapped_opdef.derived_from = test_op | ||
test_op.derived_ops = {"mapped": mapped_opdef} | ||
|
||
test_node = graph.OutputNode( | ||
types.List(types.Number()), | ||
"mapped_run-base_op", | ||
{ | ||
"run": graph.OutputNode( | ||
tagged_value_type.TaggedValueType(types.TypedDict({"project": wdt.ProjectType}), types.List(wdt.RunType)), | ||
"limit", | ||
{ | ||
"arr": graph.OutputNode( | ||
tagged_value_type.TaggedValueType( | ||
types.TypedDict({"project": wdt.ProjectType}), | ||
types.List(wdt.RunType) | ||
), | ||
"project-filteredRuns", | ||
{} | ||
) | ||
} | ||
) | ||
} | ||
) | ||
|
||
def mock_key_fn(ip, input_type): | ||
return types.List(types.Number()) | ||
|
||
result = _propagate_gql_keys_for_node(mapped_opdef, test_node, mock_key_fn, None) | ||
|
||
assert isinstance(result, tagged_value_type.TaggedValueType) | ||
# existing project tag from inputs flowed to output | ||
assert result.tag.property_types["project"] | ||
# run input propagated as tag on output | ||
assert result.value.object_type.tag.property_types["run"] | ||
assert isinstance(result.value.object_type.value, types.List) | ||
assert isinstance(result.value.object_type.value.object_type, types.Number) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters