Skip to content

Commit 2293109

Browse files
committed
Include "new" case; add clarifying comments; add error message for exception #107
1 parent 8ffd567 commit 2293109

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/sasctl/pzmm/importModel.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,20 @@ def model_exists(project, name, force, versionName="latest"):
7575
projectId = project["id"]
7676
projectVersions = mr.list_project_versions(project)
7777
if versionName == "latest":
78+
# The "latest" option specifies the most recently created version of the project. Search only in that version.
7879
modTime = [item["modified"] for item in projectVersions]
7980
latestVersion = modTime.index(max(modTime))
8081
versionId = projectVersions[latestVersion]["id"]
82+
elif versionName == "new":
83+
# The "new" option specifies a new project version, so no models with the same name will exist already.
84+
return
8185
else:
86+
# Otherwise, search for the version name specified. If the version name is not found, produce an error message.
8287
for version in projectVersions:
8388
if versionName == version["name"]:
8489
versionId = version["id"]
8590
break
91+
ValueError("No version with the name specified could be found in the project.")
8692
projectModels = mr.get(
8793
"/projects/{}/projectVersions/{}/models".format(projectId, versionId)
8894
)

0 commit comments

Comments
 (0)