@@ -32,9 +32,11 @@ def getZippedModel(model, gPath, project=None):
32
32
params = {"format" : "zip" }
33
33
modelZip = mr .get ("models/%s" % (model ), params = params , format_ = "content" )
34
34
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
36
36
if isinstance (project , RestObj ):
37
37
projectName = project .name
38
+ elif project is None :
39
+ projectName = mr .get_model (model ).projectName
38
40
else :
39
41
projectName = mr .get_project (project ).name
40
42
# Check to see if project folder exists
@@ -58,7 +60,7 @@ def getZippedModel(model, gPath, project=None):
58
60
newDir = Path (gPath ) / projectName / modelName
59
61
newDir .mkdir (parents = True , exist_ok = True )
60
62
with open (
61
- Path (gPath ) / (projectName + "/" + modelName + ".zip" ), "wb"
63
+ Path (gPath ) / (projectName + "/" + modelName + "/" + modelName + " .zip" ), "wb"
62
64
) as zFile :
63
65
zFile .write (modelZip )
64
66
@@ -253,6 +255,10 @@ def pushGitModel(cls, gPath, modelName=None, projectName=None):
253
255
zFile .write (str (file ), arcname = file .name )
254
256
with open (modelDir / (modelDir .name + ".zip" ), "rb" ) as zFile :
255
257
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
256
262
# Check if model with same name already exists in project. Delete if it exists.
257
263
model_exists (projectName , modelName , True )
258
264
mr .import_model_from_zip (modelName , projectName , zipIOFile )
@@ -294,7 +300,7 @@ def gitRepoPull(cls, gPath, branch="origin"):
294
300
pullBranch .pull ()
295
301
296
302
@classmethod
297
- def pullGitProject (cls , gPath , project = None ):
303
+ def pushGitProject (cls , gPath , project = None ):
298
304
"""Using a user provided project name, search for the project in the specified git repository,
299
305
check if the project already exists on SAS Model Manager (create a new project if it does not),
300
306
then upload each model found in the git project to SAS Model Manager
0 commit comments