From 818d4c9cefd7e50ea0752491de5b81c1526e0d2b Mon Sep 17 00:00:00 2001 From: samyarpotlapalli Date: Fri, 18 Oct 2024 15:03:58 -0400 Subject: [PATCH] added cas gateway optional parameter --- src/sasctl/_services/score_definitions.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/sasctl/_services/score_definitions.py b/src/sasctl/_services/score_definitions.py index 50c4d2e6..6146878e 100644 --- a/src/sasctl/_services/score_definitions.py +++ b/src/sasctl/_services/score_definitions.py @@ -4,7 +4,7 @@ from pathlib import Path import json -from typing import Union +from typing import Union, Optional from ..core import current_session, delete, get, sasctl_command, RestObj from .cas_management import CASManagement @@ -41,6 +41,7 @@ def create_score_definition( score_def_name: str, model: Union[str, dict], table_name: str, + use_cas_gateway: Optional[bool] = False, table_file: Union[str, Path] = None, description: str = "", server_name: str = "cas-shared-default", @@ -57,6 +58,8 @@ def create_score_definition( The name or id of the model, or a dictionary representation of the model. table_name: str A user-inputted table name in CAS Management. + use_cas_gateway: bool, optional + Determines whether object uses CAS Gateway or not. table_file: str or Path, optional A user-provided path to an uploadable file. Defaults to None. description: str, optional @@ -73,6 +76,12 @@ def create_score_definition( RestObj """ + # Changes object descriptor type to either use or not use CAS Gateway + object_descriptor_type: str + if use_cas_gateway: + object_descriptor_type = "sas.models.model.python" + else: + object_descriptor_type = "sas.models.model.ds2" model = cls._model_repository.get_model(model) @@ -120,12 +129,12 @@ def create_score_definition( # Checks if the inputted table exists, and if not, uploads a file to create a new table save_score_def = { - "name": score_def_name, + "name": model_name, # used to be score_def_name "description": description, "objectDescriptor": { "uri": f"/modelManagement/models/{model_id}", "name": f"{model_name}({model_version})", - "type": "sas.models.model.python", + "type": f"{object_descriptor_type}", }, "inputData": { "type": "CASTable",