Skip to content

Commit 841d8ec

Browse files
committed
Fixed bug in create_performance_definition regarding passing in model and project
1 parent e866b91 commit 841d8ec

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/sasctl/_services/model_management.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,22 @@ def create_performance_definition(
204204

205205
# Separate single models from multiple models
206206
if not isinstance(models, list):
207-
models = mr.get_model(models)
207+
models = [models]
208+
if project:
209+
project = mr.get_project(project)
210+
project_models = mr.get(f'/projects/{project.id}/models')
211+
project_models = [m for m in project_models if m.name in models]
212+
models = project_models
213+
# Necessary to eventually provide variables to the performance definition
214+
models[0] = mr.get_model(project_models[0].id)
208215
else:
209216
# Collect all models into a list. This converts the PagedList response from mr.list_models to a normal list.
210217
for i, model in enumerate(models):
211218
models[i] = mr.get_model(model)
212-
if not project:
213219
project = mr.get_project(models[0].projectId)
220+
# Ensures that all models are in the same project
221+
if not all([model.projectId == project.id for model in models]):
222+
raise ValueError("Not all models are contained within the same project. Try specifying a project.")
214223

215224
# Performance data cannot be captured unless certain project properties have been configured.
216225
for required in ["targetVariable", "targetLevel"]:

0 commit comments

Comments
 (0)