@@ -80,11 +80,11 @@ def _upload_additional_resources(self, model_instance):
80
80
return model_instance
81
81
82
82
def _copy_or_move_hopsfs_model_item (
83
- self , item_attr , to_model_version_path , keep_original_files
83
+ self , item_attr , to_model_files_path , keep_original_files
84
84
):
85
85
"""Copy or move model item from a hdfs path to the model version folder in the Models dataset. It works with files and folders."""
86
86
path = item_attr ["path" ]
87
- to_hdfs_path = os .path .join (to_model_version_path , os .path .basename (path ))
87
+ to_hdfs_path = os .path .join (to_model_files_path , os .path .basename (path ))
88
88
if keep_original_files :
89
89
self ._engine .copy (path , to_hdfs_path )
90
90
else :
@@ -93,7 +93,7 @@ def _copy_or_move_hopsfs_model_item(
93
93
def _copy_or_move_hopsfs_model (
94
94
self ,
95
95
from_hdfs_model_path ,
96
- to_model_version_path ,
96
+ to_model_files_path ,
97
97
keep_original_files ,
98
98
update_upload_progress ,
99
99
):
@@ -122,7 +122,7 @@ def _copy_or_move_hopsfs_model(
122
122
)["items" ]:
123
123
path_attr = entry ["attributes" ]
124
124
self ._copy_or_move_hopsfs_model_item (
125
- path_attr , to_model_version_path , keep_original_files
125
+ path_attr , to_model_files_path , keep_original_files
126
126
)
127
127
if path_attr .get ("dir" , False ):
128
128
n_dirs += 1
@@ -132,7 +132,7 @@ def _copy_or_move_hopsfs_model(
132
132
else :
133
133
# if path is a file, copy/move it
134
134
self ._copy_or_move_hopsfs_model_item (
135
- model_path_attr , to_model_version_path , keep_original_files
135
+ model_path_attr , to_model_files_path , keep_original_files
136
136
)
137
137
n_files += 1
138
138
update_upload_progress (n_dirs = n_dirs , n_files = n_files )
@@ -156,7 +156,7 @@ def _download_model_from_hopsfs_recursive(
156
156
157
157
if path_attr .get ("dir" , False ):
158
158
# otherwise, make a recursive call for the folder
159
- if basename == "Artifacts" :
159
+ if basename == constants . MODEL_REGISTRY . ARTIFACTS_DIR_NAME :
160
160
continue # skip Artifacts subfolder
161
161
local_folder_path = os .path .join (to_local_path , basename )
162
162
os .mkdir (local_folder_path )
@@ -195,11 +195,11 @@ def _download_model_from_hopsfs(
195
195
def _upload_local_model (
196
196
self ,
197
197
from_local_model_path ,
198
- to_model_version_path ,
198
+ to_model_files_path ,
199
199
update_upload_progress ,
200
200
upload_configuration = None ,
201
201
):
202
- """Copy or upload model files from a local path to the model version folder in the Models dataset."""
202
+ """Copy or upload model files from a local path to the model files folder in the Models dataset."""
203
203
n_dirs , n_files = 0 , 0
204
204
if os .path .isdir (from_local_model_path ):
205
205
# if path is a dir, upload files and folders iteratively
@@ -210,7 +210,7 @@ def _upload_local_model(
210
210
# - files is the list of file names present in the root dir
211
211
# we need to replace the local path prefix with the hdfs path prefix (i.e., /srv/hops/....../root with /Projects/.../)
212
212
remote_base_path = root .replace (
213
- from_local_model_path , to_model_version_path
213
+ from_local_model_path , to_model_files_path
214
214
)
215
215
for d_name in dirs :
216
216
self ._engine .mkdir (remote_base_path + "/" + d_name )
@@ -228,7 +228,7 @@ def _upload_local_model(
228
228
# if path is a file, upload file
229
229
self ._engine .upload (
230
230
from_local_model_path ,
231
- to_model_version_path ,
231
+ to_model_files_path ,
232
232
upload_configuration = upload_configuration ,
233
233
)
234
234
n_files += 1
@@ -249,14 +249,14 @@ def _save_model_from_local_or_hopsfs_mount(
249
249
from_hdfs_model_path = model_path .replace (
250
250
constants .MODEL_REGISTRY .HOPSFS_MOUNT_PREFIX , ""
251
251
),
252
- to_model_version_path = model_instance .version_path ,
252
+ to_model_files_path = model_instance .files_path ,
253
253
keep_original_files = keep_original_files ,
254
254
update_upload_progress = update_upload_progress ,
255
255
)
256
256
else :
257
257
self ._upload_local_model (
258
258
from_local_model_path = model_path ,
259
- to_model_version_path = model_instance .version_path ,
259
+ to_model_files_path = model_instance .files_path ,
260
260
update_upload_progress = update_upload_progress ,
261
261
upload_configuration = upload_configuration ,
262
262
)
@@ -365,6 +365,7 @@ def save(
365
365
if step ["id" ] == 0 :
366
366
# Create folders
367
367
self ._engine .mkdir (model_instance .version_path )
368
+ self ._engine .mkdir (model_instance .files_path )
368
369
if step ["id" ] == 1 :
369
370
370
371
def update_upload_progress (n_dirs = 0 , n_files = 0 , step = step ):
@@ -374,7 +375,7 @@ def update_upload_progress(n_dirs=0, n_files=0, step=step):
374
375
375
376
update_upload_progress (n_dirs = 0 , n_files = 0 )
376
377
377
- # Upload Model files from local path to /Models/{model_instance._name}/{model_instance._version}
378
+ # Upload Model files from local path to /Models/{model_instance._name}/{model_instance._version}/Files
378
379
# check local absolute
379
380
if os .path .isabs (model_path ) and os .path .exists (model_path ):
380
381
self ._save_model_from_local_or_hopsfs_mount (
@@ -401,7 +402,7 @@ def update_upload_progress(n_dirs=0, n_files=0, step=step):
401
402
): # check hdfs relative and absolute
402
403
self ._copy_or_move_hopsfs_model (
403
404
from_hdfs_model_path = model_path ,
404
- to_model_version_path = model_instance .version_path ,
405
+ to_model_files_path = model_instance .files_path ,
405
406
keep_original_files = keep_original_files ,
406
407
update_upload_progress = update_upload_progress ,
407
408
)
@@ -446,7 +447,7 @@ def update_download_progress(n_dirs, n_files, done=False):
446
447
)
447
448
448
449
try :
449
- from_hdfs_model_path = model_instance .version_path
450
+ from_hdfs_model_path = model_instance .files_path
450
451
if from_hdfs_model_path .startswith ("hdfs:/" ):
451
452
projects_index = from_hdfs_model_path .find ("/Projects" , 0 )
452
453
from_hdfs_model_path = from_hdfs_model_path [projects_index :]
0 commit comments