Skip to content

Commit 4744997

Browse files
committed
Avoid uploading default params several times
1 parent 6a7f344 commit 4744997

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

giskard/core/suite.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
1+
from typing import Any, Dict, List, Optional, Tuple, Union
2+
13
import inspect
24
import logging
35
import traceback
46
from dataclasses import dataclass
57
from functools import singledispatchmethod
6-
from typing import List, Any, Union, Dict, Optional, Tuple
78

89
from mlflow import MlflowClient
910

10-
from giskard.client.dtos import TestSuiteDTO, TestInputDTO, SuiteTestDTO
11+
from giskard.client.dtos import SuiteTestDTO, TestInputDTO, TestSuiteDTO
1112
from giskard.client.giskard_client import GiskardClient
1213
from giskard.core.core import TestFunctionMeta
1314
from giskard.datasets.base import Dataset
1415
from giskard.ml_worker.core.savable import Artifact
1516
from giskard.ml_worker.exceptions.IllegalArgumentError import IllegalArgumentError
16-
from giskard.ml_worker.testing.registry.giskard_test import (
17-
GiskardTest,
18-
Test,
19-
GiskardTestMethod,
20-
)
17+
from giskard.ml_worker.testing.registry.giskard_test import GiskardTest, GiskardTestMethod, Test
2118
from giskard.ml_worker.testing.registry.registry import tests_registry
2219
from giskard.ml_worker.testing.registry.slicing_function import SlicingFunction
23-
from giskard.ml_worker.testing.registry.transformation_function import (
24-
TransformationFunction,
25-
)
26-
from giskard.ml_worker.testing.test_result import (
27-
TestResult,
28-
TestMessage,
29-
TestMessageLevel,
30-
)
20+
from giskard.ml_worker.testing.registry.transformation_function import TransformationFunction
21+
from giskard.ml_worker.testing.test_result import TestMessage, TestMessageLevel, TestResult
3122
from giskard.models.base import BaseModel
3223

3324
logger = logging.getLogger(__name__)
@@ -97,6 +88,7 @@ def _repr_html_(self):
9788

9889
def to_mlflow(self, mlflow_client: MlflowClient = None, mlflow_run_id: str = None):
9990
import mlflow
91+
10092
from giskard.integrations.mlflow.giskard_evaluator_utils import process_text
10193

10294
metrics = dict()
@@ -122,8 +114,10 @@ def to_wandb(self, **kwargs) -> None:
122114
Additional keyword arguments
123115
(see https://docs.wandb.ai/ref/python/init) to be added to the active WandB run.
124116
"""
125-
from giskard.integrations.wandb.wandb_utils import wandb_run, _parse_test_name
126117
import wandb
118+
119+
from giskard.integrations.wandb.wandb_utils import _parse_test_name, wandb_run
120+
127121
from ..utils.analytics_collector import analytics
128122

129123
with wandb_run(**kwargs) as run:
@@ -426,22 +420,25 @@ def upload(self, client: GiskardClient, project_key: str):
426420
"""
427421
if self.name is None:
428422
self.name = "Unnamed test suite"
429-
423+
424+
uploaded_uuids: List[str] = []
430425
# Upload the default parameters if they are model or dataset
431426
for arg in self.default_params.values():
432427
if isinstance(arg, BaseModel) or isinstance(arg, Dataset):
433428
arg.upload(client, project_key)
429+
uploaded_uuids.append(str(arg.id))
434430

435-
self.id = client.save_test_suite(self.to_dto(client, project_key))
431+
self.id = client.save_test_suite(self.to_dto(client, project_key, uploaded_uuids))
436432
project_id = client.get_project(project_key).project_id
437433
print(f"Test suite has been saved: {client.host_url}/main/projects/{project_id}/test-suite/{self.id}/overview")
438434
return self
439435

440-
def to_dto(self, client: GiskardClient, project_key: str):
436+
def to_dto(self, client: GiskardClient, project_key: str, uploaded_uuids: Optional[List[str]] = None):
441437
suite_tests: List[SuiteTestDTO] = list()
442438

443439
# Avoid to upload the same artifacts several times
444-
uploaded_uuids: List[str] = []
440+
if uploaded_uuids is None:
441+
uploaded_uuids = []
445442

446443
for t in self.tests:
447444
suite_tests.append(

0 commit comments

Comments
 (0)