Skip to content

Commit

Permalink
Merge pull request #1059 from tensorlakeai/eugene-test-fixes
Browse files Browse the repository at this point in the history
Fix broken tests and delete function image tests
  • Loading branch information
eabatalov authored Nov 22, 2024
2 parents 135745a + 78524a6 commit 1b0cf4a
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 298 deletions.
Empty file.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

19 changes: 18 additions & 1 deletion python-sdk/tests/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
#!/bin/bash

set -ex
if [[ -z "$INDEXIFY_URL" ]]; then
echo "Please set INDEXIFY_URL environment variable to specify"\
"Indexify Server you are testing." \
"Example: 'export INDEXIFY_URL=http://localhost:8900'" 1>&2
exit 1
fi

# Run each test file one by one sequentially. Returns non zero status
# code if any of the test commands return non zero status code. Doesn't
# stop if a test command fails.
find . -name 'test_*.py' | xargs -L1 poetry run python
TESTS_EXIT_CODE=$?

if [ $TESTS_EXIT_CODE -eq 0 ]; then
echo "All tests passed!"
else
echo "One or more tests failed. Please check output log for details."
fi

exit $TESTS_EXIT_CODE
6 changes: 4 additions & 2 deletions python-sdk/tests/test_broken_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ def test_broken_graph(self):
g = RemoteGraph.deploy(g)

self.assertRaises(
Exception,
g.run(
block_until_done=True,
url="https://www.youtube.com/watch?v=gjHv4pM8WEQ",
)
),
)

self.assertRaises(
Exception,
g.run(
block_until_done=True,
maybe="https://www.youtube.com/watch?v=gjHv4pM8WEQ",
)
),
)


Expand Down
15 changes: 10 additions & 5 deletions python-sdk/tests/test_function_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
from indexify.executor.function_worker import FunctionWorker
from indexify.functions_sdk.data_objects import File, IndexifyData
from indexify.functions_sdk.indexify_functions import (
GraphInvocationContext,
IndexifyFunctionWrapper,
indexify_function,
)
from indexify.functions_sdk.object_serializer import CloudPickleSerializer


@indexify_function()
Expand Down Expand Up @@ -95,12 +97,14 @@ async def test_function_worker_happy_path(self):
),
code_path=temp_file_path,
version=1,
invocation_id="123",
)
fn_wrapper = IndexifyFunctionWrapper(extractor_b)
fn_outputs = []
for worker_output in fn_worker_output.fn_outputs:
self.assertEqual(worker_output.payload_encoding, "cloudpickle")
fn_outputs.append(fn_wrapper.deserialize_fn_output(worker_output))
self.assertEqual(worker_output.encoder, "cloudpickle")
fn_outputs.append(
CloudPickleSerializer.deserialize(worker_output.payload)
)
self.assertEqual(len(fn_outputs), 2)
expected = FileChunk(data=b"hello", start=5, end=5)

Expand All @@ -110,7 +114,7 @@ async def test_function_worker_extractor_raises_error(self):
g = create_graph_exception()

with tempfile.NamedTemporaryFile(delete=True) as temp_file:
code_bytes = cloudpickle.dumps(g.serialize())
code_bytes = cloudpickle.dumps(g.serialize(additional_modules=[]))

temp_file.write(code_bytes)
temp_file.flush()
Expand All @@ -123,9 +127,10 @@ async def test_function_worker_extractor_raises_error(self):
input=IndexifyData(id="123", payload=cloudpickle.dumps(10)),
code_path=temp_file_path,
version=1,
invocation_id="123",
)
assert not result.success
assert result.exception == "this extractor throws an exception."
assert "this extractor throws an exception." in result.stderr


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 1b0cf4a

Please sign in to comment.