@@ -1045,17 +1045,33 @@ def upload_local_model(
1045
1045
# Get project from repo if it exists; if it doesn't, create a new one
1046
1046
p = mr .get_project (project_name )
1047
1047
if p is None :
1048
- mr .create_project (project_name , repository )
1048
+ p = mr .create_project (project_name , repository )
1049
1049
1050
1050
# zip up all files in directory (except any previous zip files)
1051
1051
zip_name = str (Path (path ) / (model_name + ".zip" ))
1052
- file_names = sorted (Path (path ).glob ("*[!zip]" ))
1053
- with zipfile .ZipFile (str (zip_name ), mode = "w" ) as zFile :
1052
+ file_names = sorted (Path (path ).glob ("*[!(zip|sasast)]" ))
1053
+ sasast_file = next (Path (path ).glob ("*.sasast" ), None )
1054
+ if sasast_file :
1055
+ # If a sasast file is present, upload it as well
1056
+ with open (sasast_file , "rb" ) as sasast :
1057
+ sasast_model = sasast .read ()
1058
+ data = {
1059
+ "name" : model_name ,
1060
+ "projectId" : p .id ,
1061
+ "type" : "ASTORE" ,
1062
+ }
1063
+ files = {"files" : (sasast_file .name , sasast_model )}
1064
+ model = mr .post ("/models" , files = files , data = data )
1054
1065
for file in file_names :
1055
- zFile .write (str (file ), arcname = file .name )
1056
- # upload zipped model
1057
- with open (zip_name , "rb" ) as zip_file :
1058
- model = mr .import_model_from_zip (
1059
- model_name , project_name , zip_file , version = version
1060
- )
1066
+ with open (file , "r" ) as f :
1067
+ mr .add_model_content (model , f , file .name )
1068
+ else :
1069
+ with zipfile .ZipFile (str (zip_name ), mode = "w" ) as zFile :
1070
+ for file in file_names :
1071
+ zFile .write (str (file ), arcname = file .name )
1072
+ # upload zipped model
1073
+ with open (zip_name , "rb" ) as zip_file :
1074
+ model = mr .import_model_from_zip (
1075
+ model_name , project_name , zip_file , version = version
1076
+ )
1061
1077
return model
0 commit comments