|
13 | 13 | import pickle # skipcq BAN-B301
|
14 | 14 | import re
|
15 | 15 | import sys
|
| 16 | +from pathlib import Path |
| 17 | +from typing import Union |
16 | 18 | from warnings import warn
|
17 | 19 |
|
18 | 20 | import pandas as pd
|
|
30 | 32 | from .services import model_management as mm
|
31 | 33 | from .services import model_publish as mp
|
32 | 34 | from .services import model_repository as mr
|
| 35 | +from .services import score_definitions as sd |
| 36 | +from .services import score_execution as se |
33 | 37 | from .utils.misc import installed_packages
|
34 | 38 | from .utils.pymas import from_pickle
|
35 | 39 |
|
@@ -1008,3 +1012,30 @@ def get_project_kpis(
|
1008 | 1012 | kpiTableDf = kpiTableDf.apply(lambda x: x.str.strip()).replace([".", ""], None)
|
1009 | 1013 |
|
1010 | 1014 | return kpiTableDf
|
| 1015 | + |
| 1016 | + |
| 1017 | +def score_model_with_cas( |
| 1018 | + score_def_name: str, |
| 1019 | + model: Union[str, dict], |
| 1020 | + table_name: str, |
| 1021 | + table_file: Union[str, Path] = None, |
| 1022 | + description: str = "", |
| 1023 | + server_name: str = "cas-shared-default", |
| 1024 | + library_name: str = "Public", |
| 1025 | + model_version: str = "latest" |
| 1026 | +): |
| 1027 | + score_definition = sd.create_score_definition( |
| 1028 | + score_def_name, |
| 1029 | + model, |
| 1030 | + table_name, |
| 1031 | + table_file=table_file, |
| 1032 | + description=description, |
| 1033 | + server_name=server_name, |
| 1034 | + library_name=library_name, |
| 1035 | + model_version=model_version |
| 1036 | + ) |
| 1037 | + score_execution = se.create_score_execution(score_definition.id) |
| 1038 | + score_execution_poll = se.poll_score_execution_state(score_execution) |
| 1039 | + print(score_execution_poll) |
| 1040 | + score_results = se.get_score_execution_results(score_execution) |
| 1041 | + return score_results |
0 commit comments