Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion giskard/ml_worker/websocket/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from enum import Enum
from typing import Dict, List, Optional

import pydantic
from packaging import version
from pydantic import Field
from typing import Dict, List, Optional

from giskard.core.validation import ConfiguredBaseModel

Expand Down Expand Up @@ -323,6 +323,7 @@ class TestSuite(WorkerReply):


class TestSuiteParam(ConfiguredBaseModel):
projectKey: str
tests: Optional[List[SuiteTestArgument]] = None
globalArguments: Optional[List[FuncArgument]] = None

Expand Down
4 changes: 2 additions & 2 deletions giskard/ml_worker/websocket/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from copy import copy
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Callable, Dict, Optional, Union

import numpy as np
import pandas as pd
import pkg_resources
import psutil
from typing import Any, Callable, Dict, Optional, Union

import giskard
from giskard.client.giskard_client import GiskardClient
Expand Down Expand Up @@ -562,7 +562,7 @@ def run_test_suite(
identifier_single_test_results.append(
websocket.IdentifierSingleTestResult(
id=identifier,
result=map_result_to_single_test_result_ws(result, datasets),
result=map_result_to_single_test_result_ws(result, datasets, client, params.projectKey),
arguments=function_argument_to_ws(arguments),
)
)
Expand Down
3 changes: 3 additions & 0 deletions tests/communications/fixtures/with_alias.json
Original file line number Diff line number Diff line change
Expand Up @@ -2866,10 +2866,12 @@
],
"TestSuiteParam": [
{
"projectKey": "my_project",
"tests": [],
"globalArguments": []
},
{
"projectKey": "awesome_project",
"tests": [
{
"id": 2201,
Expand Down Expand Up @@ -2942,6 +2944,7 @@
"globalArguments": []
},
{
"projectKey": "amazing_project",
"tests": [
{
"id": 5848,
Expand Down
4 changes: 2 additions & 2 deletions tests/communications/test_dto_serialization.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import json
from pathlib import Path
from typing import Dict, List, Optional, Type

import pydantic
import pytest
from packaging import version
from polyfactory.factories.pydantic_factory import ModelFactory
from pydantic import BaseModel
from typing import Dict, List, Optional, Type

import giskard
import giskard.ml_worker.websocket
Expand Down Expand Up @@ -80,7 +80,7 @@
"TestFunctionArgument": ["name", "type", "optional", "default", "argOrder"],
"TestMessage": ["type", "text"],
"TestSuite": ["is_error", "is_pass", "logs"],
"TestSuiteParam": [],
"TestSuiteParam": ["projectKey"],
"WeightsPerFeature": [],
"WorkerReply": [],
}
Expand Down
42 changes: 42 additions & 0 deletions tests/communications/test_websocket_actor_tests.py
Copy link
Member

Choose a reason for hiding this comment

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

Do you think whether we need a test case with my_simple_test_legacy_debug_no_name, which does set output_df?

This is to make sure that the upload code in test suite running is covered.
We forgot it last time, which causes the issue.
I can do it if you agree but do not have much time ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

I can add one test RN

Copy link
Member Author

Choose a reason for hiding this comment

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

I added the test

Copy link
Member

Choose a reason for hiding this comment

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

Thanks very much!

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import uuid

import pandas as pd
import pytest

from giskard import test
Expand All @@ -21,6 +22,11 @@ def my_simple_test_successful():
return GiskardTestResult(passed=True)


@test
def my_simple_test__legacy_debug():
return GiskardTestResult(passed=True, output_df=Dataset(pd.DataFrame({"test": [1]})))


@test
def my_simple_test_error():
raise ValueError("Actively raise an error in the test.")
Expand Down Expand Up @@ -299,6 +305,7 @@ def test_websocket_actor_run_ad_hoc_test_legacy_debug_no_name(enron_data: Datase
def test_websocket_actor_run_test_suite():
with utils.MockedClient(mock_all=False) as (client, mr):
params = websocket.TestSuiteParam(
projectKey=str(uuid.uuid4()),
tests=[
websocket.SuiteTestArgument(
id=0,
Expand Down Expand Up @@ -339,6 +346,7 @@ def test_websocket_actor_run_test_suite():
def test_websocket_actor_run_test_suite_raise_error():
with utils.MockedClient(mock_all=False) as (client, mr):
params = websocket.TestSuiteParam(
projectKey=str(uuid.uuid4()),
tests=[
websocket.SuiteTestArgument(
id=0,
Expand Down Expand Up @@ -372,6 +380,7 @@ def my_test_return(value: int = MY_TEST_DEFAULT_VALUE):
def test_websocket_actor_run_test_suite_with_global_arguments():
with utils.MockedClient(mock_all=False) as (client, mr):
params = websocket.TestSuiteParam(
projectKey=str(uuid.uuid4()),
tests=[
websocket.SuiteTestArgument(
id=0,
Expand Down Expand Up @@ -406,6 +415,7 @@ def test_websocket_actor_run_test_suite_with_global_arguments():
def test_websocket_actor_run_test_suite_with_test_input():
with utils.MockedClient(mock_all=False) as (client, mr):
params = websocket.TestSuiteParam(
projectKey=str(uuid.uuid4()),
tests=[
websocket.SuiteTestArgument(
id=0,
Expand Down Expand Up @@ -437,9 +447,41 @@ def test_websocket_actor_run_test_suite_with_test_input():
)


def test_websocket_actor_run_test_suite_with_legacy_debug():
with utils.MockedClient(mock_all=False) as (client, mr):
params = websocket.TestSuiteParam(
projectKey=str(uuid.uuid4()),
tests=[
websocket.SuiteTestArgument(
id=0,
testUuid=my_simple_test__legacy_debug.meta.uuid,
arguments=[
websocket.FuncArgument(name="value", int=MY_TEST_INPUT_VALUE, none=False),
],
),
],
globalArguments=[
websocket.FuncArgument(name="value", int=MY_TEST_GLOBAL_VALUE, none=False),
],
)
utils.register_uri_for_artifact_meta_info(mr, my_simple_test__legacy_debug, None)
utils.register_uri_for_any_dataset_artifact_info_upload(mr, True)

reply = listener.run_test_suite(client, params)

assert isinstance(reply, websocket.TestSuite)
assert not reply.is_error, reply.logs
assert reply.is_pass

assert 1 == len(reply.results)
assert 0 == reply.results[0].id
assert reply.results[0].result.passed


def test_websocket_actor_run_test_suite_with_kwargs():
with utils.MockedClient(mock_all=False) as (client, mr):
params = websocket.TestSuiteParam(
projectKey=str(uuid.uuid4()),
tests=[
websocket.SuiteTestArgument(
id=0,
Expand Down