Skip to content

Commit fa248a2

Browse files
committed
feat: add new task to score models in SAS Model Manager
1 parent 4f9ab4d commit fa248a2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/sasctl/tasks.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import pickle # skipcq BAN-B301
1414
import re
1515
import sys
16+
from pathlib import Path
17+
from typing import Union
1618
from warnings import warn
1719

1820
import pandas as pd
@@ -30,6 +32,8 @@
3032
from .services import model_management as mm
3133
from .services import model_publish as mp
3234
from .services import model_repository as mr
35+
from .services import score_definitions as sd
36+
from .services import score_execution as se
3337
from .utils.misc import installed_packages
3438
from .utils.pymas import from_pickle
3539

@@ -1008,3 +1012,30 @@ def get_project_kpis(
10081012
kpiTableDf = kpiTableDf.apply(lambda x: x.str.strip()).replace([".", ""], None)
10091013

10101014
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

Comments
 (0)