Skip to content

Commit cb2c0af

Browse files
committed
Fix minor git integration bugs
1 parent b3c5302 commit cb2c0af

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/sasctl/pzmm/gitIntegration.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ def getZippedModel(model, gPath, project=None):
3232
params = {"format": "zip"}
3333
modelZip = mr.get("models/%s" % (model), params=params, format_="content")
3434
modelName = mr.get_model(model).name
35-
# Check if the provided project variable is a REST object
35+
# Check project argument to determine project name
3636
if isinstance(project, RestObj):
3737
projectName = project.name
38+
elif project is None:
39+
projectName = mr.get_model(model).projectName
3840
else:
3941
projectName = mr.get_project(project).name
4042
# Check to see if project folder exists
@@ -58,7 +60,7 @@ def getZippedModel(model, gPath, project=None):
5860
newDir = Path(gPath) / projectName / modelName
5961
newDir.mkdir(parents=True, exist_ok=True)
6062
with open(
61-
Path(gPath) / (projectName + "/" + modelName + ".zip"), "wb"
63+
Path(gPath) / (projectName + "/" + modelName + "/" + modelName + ".zip"), "wb"
6264
) as zFile:
6365
zFile.write(modelZip)
6466

@@ -253,6 +255,10 @@ def pushGitModel(cls, gPath, modelName=None, projectName=None):
253255
zFile.write(str(file), arcname=file.name)
254256
with open(modelDir / (modelDir.name + ".zip"), "rb") as zFile:
255257
zipIOFile = io.BytesIO(zFile.read())
258+
# Check to see if provided project argument is a valid project on SAS Model Manager
259+
projectResponse = mr.get_project(projectName)
260+
project = project_exists(projectResponse, projectName)
261+
projectName = project.name
256262
# Check if model with same name already exists in project. Delete if it exists.
257263
model_exists(projectName, modelName, True)
258264
mr.import_model_from_zip(modelName, projectName, zipIOFile)
@@ -294,7 +300,7 @@ def gitRepoPull(cls, gPath, branch="origin"):
294300
pullBranch.pull()
295301

296302
@classmethod
297-
def pullGitProject(cls, gPath, project=None):
303+
def pushGitProject(cls, gPath, project=None):
298304
"""Using a user provided project name, search for the project in the specified git repository,
299305
check if the project already exists on SAS Model Manager (create a new project if it does not),
300306
then upload each model found in the git project to SAS Model Manager

0 commit comments

Comments
 (0)