55from .ml import DSSTrainedClusteringModelDetails
66from .ml import DSSTrainedPredictionModelDetails
77
8+ from ..utils import make_zipfile
9+
810try :
911 basestring
1012except NameError :
@@ -119,15 +121,15 @@ def get_origin_ml_task(self):
119121 if fmi is not None :
120122 return DSSMLTask .from_full_model_id (self .client , fmi , project_key = self .project_key )
121123
122- def import_mlflow_version_from_path (self , version_id , path , code_env_name = "INHERIT" ):
124+ def import_mlflow_version_from_path (self , version_id , path , code_env_name = "INHERIT" ):
123125 """
124126 Create a new version for this saved model from a path containing a MLFlow model.
125127
126128 Requires the saved model to have been created using :meth:`dataikuapi.dss.project.DSSProject.create_mlflow_pyfunc_model`.
127129
128130 :param str version_id: Identifier of the version to create
129131 :param str path: An absolute path on the local filesystem. Must be a folder, and must contain a MLFlow model
130- :param str code_env_name: Name of the code env to use for this model version. The code env must contain at least
132+ :param str code_env_name: Name of the code env to use for this model version. The code env must contain at least
131133 mlflow and the package(s) corresponding to the used MLFlow-compatible frameworks.
132134 If value is "INHERIT", the default active code env of the project will be used
133135 :return a :class:MLFlowVersionHandler in order to interact with the new MLFlow model version
@@ -136,13 +138,14 @@ def import_mlflow_version_from_path(self, version_id, path, code_env_name = "INH
136138 # TODO: cleanup the archive
137139 import shutil
138140 import os
141+
139142 archive_temp_dir = tempfile .mkdtemp ()
140143 try :
141- archive_filename = shutil . make_archive (os .path .join (archive_temp_dir , "tmpmodel" ), " zip", path ) #[, root_dir[, base_dir[, verbose[, dry_run[, owner[, group[, logger]]]]]]] )
144+ archive_filename = make_zipfile (os .path .join (archive_temp_dir , "tmpmodel. zip" ), path )
142145
143146 with open (archive_filename , "rb" ) as fp :
144147 self .client ._perform_empty ("POST" , "/projects/%s/savedmodels/%s/versions/%s?codeEnvName=%s" % (self .project_key , self .sm_id , version_id , code_env_name ),
145- files = {"file" :(archive_filename , fp )})
148+ files = {"file" : (archive_filename , fp )})
146149 return self .get_mlflow_version_handler (version_id )
147150 finally :
148151 shutil .rmtree (archive_temp_dir )
0 commit comments