Skip to content

Commit 6fe860f

Browse files
committed
Websocket handle kwargs
1 parent 36cc78c commit 6fe860f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

giskard/ml_worker/websocket/utils.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
from typing import Any, Dict, List, Optional
2-
31
import logging
42
import os
53
import posixpath
64
import shutil
75
from pathlib import Path
6+
from typing import Any, Dict, List, Optional
87

98
from mlflow.store.artifact.artifact_repo import verify_artifact_path
109

@@ -277,6 +276,7 @@ def map_suite_input_ws(i: websocket.SuiteInput):
277276

278277
def function_argument_to_ws(value: Dict[str, Any]):
279278
args = list()
279+
kwargs = dict()
280280

281281
for v in value:
282282
obj = value[v]
@@ -310,10 +310,18 @@ def function_argument_to_ws(value: Dict[str, Any]):
310310
funcargs = websocket.FuncArgument(name=v, str=obj, none=False)
311311
elif isinstance(obj, bool):
312312
funcargs = websocket.FuncArgument(name=v, bool=obj, none=False)
313-
elif isinstance(obj, dict):
314-
funcargs = websocket.FuncArgument(name=v, kwargs=str(obj), none=False)
315313
else:
316-
raise IllegalArgumentError("Unknown argument type")
314+
kwargs[v] = obj
315+
continue
317316
args.append(funcargs)
318317

318+
if len(kwargs) > 0:
319+
args.append(
320+
websocket.FuncArgument(
321+
name="kwargs",
322+
kwargs="\n".join([f"kwargs[{repr(key)}] = {repr(value)}" for key, value in kwargs.items()]),
323+
none=False,
324+
)
325+
)
326+
319327
return args

0 commit comments

Comments
 (0)