File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -824,12 +824,24 @@ def close(self) -> None:
824824 return
825825
826826 file_paths = dict ()
827- for filename in scandir (self .cfg .work_dir , self ._artifact_suffix ,
828- True ):
829- file_path = osp .join (self .cfg .work_dir , filename )
830- relative_path = os .path .relpath (file_path , self .cfg .work_dir )
831- dir_path = os .path .dirname (relative_path )
832- file_paths [file_path ] = dir_path
827+ if (
828+ hasattr (self , 'cfg' )
829+ and osp .isdir (getattr (self .cfg , 'work_dir' , '' ))
830+ ):
831+ for filename in scandir (
832+ self .cfg .work_dir ,
833+ self ._artifact_suffix ,
834+ recursive = True ,
835+ ):
836+ file_path = str (osp .join (self .cfg .work_dir , filename ))
837+ relative_path = os .path .relpath (file_path , self .cfg .work_dir )
838+ dir_path = os .path .dirname (relative_path )
839+ file_paths [file_path ] = dir_path
840+ else :
841+ warnings .warn (
842+ 'self.cfg.work_dir is not set, thus some '
843+ 'artifacts will not be logged'
844+ )
833845
834846 for file_path , dir_path in file_paths .items ():
835847 self ._mlflow .log_artifact (file_path , dir_path )
You can’t perform that action at this time.
0 commit comments