Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for simple graph, with multiple inputs #1018

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions python-sdk/tests/test_graph_behaviours.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import unittest
from pathlib import Path
from typing import List, Union
Expand Down Expand Up @@ -28,6 +29,12 @@ def simple_function(x: MyObject) -> MyObject:
return MyObject(x=x.x + "b")


@indexify_function()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth testing if this works with json encoding as well. May be it works.

def simple_function_multiple_inputs(x: MyObject, y: int) -> MyObject:
suf = ''.join(["b" for _ in range(y)])
return MyObject(x=x.x + suf)


@indexify_function(encoder="json")
def simple_function_with_json_encoder(x: MyObject) -> MyObject:
return MyObject(x=x.x + "b")
Expand Down Expand Up @@ -208,6 +215,18 @@ def test_simple_function(self, is_remote):
output = graph.output(invocation_id, "simple_function")
self.assertEqual(output, [MyObject(x="ab")])

# @parameterized.expand([(False), (True)])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably shouldn't be commented.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran into this on my laptop testing,ModuleNotFoundError: No module named 'test_graph_behaviours'. I just pushed the PR to run the test and see if it worked. Will fix.

def test_simple_function_multiple_inputs(self, is_remote=True):
print(sys.version_info.major, sys.version_info.minor)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unintented?


graph = Graph(
name="test_simple_function2", description="test", start_node=simple_function_multiple_inputs
)
graph = remote_or_local_graph(graph, is_remote)
invocation_id = graph.run(block_until_done=True, x=MyObject(x="a"), y=10)
output = graph.output(invocation_id, "simple_function_multiple_inputs")
self.assertEqual(output, [MyObject(x="abbbbbbbbbb")])

@parameterized.expand([(False), (True)])
def test_simple_function_with_json_encoding(self, is_remote):
graph = Graph(
Expand Down
Loading