@@ -46,24 +46,24 @@ def upload_video_to_gcs(output_dir: str, video_path: str):
4646 blob = bucket .blob (destination_blob_name )
4747
4848 # Upload the file
49- print (f"Uploading { source_file_path } to { bucket_name } /{ destination_blob_name } ..." )
49+ max_logging . log (f"Uploading { source_file_path } to { bucket_name } /{ destination_blob_name } ..." )
5050 blob .upload_from_filename (source_file_path )
51- print (f"Upload complete { source_file_path } ." )
51+ max_logging . log (f"Upload complete { source_file_path } ." )
5252
5353 except Exception as e :
54- print (f"An error occurred: { e } " )
54+ max_logging . log (f"An error occurred: { e } " )
5555
5656def delete_file (file_path : str ):
5757 # Best practice: Check if the file exists before trying to delete it.
5858 if os .path .exists (file_path ):
5959 try :
6060 os .remove (file_path )
61- print (f"Successfully deleted file: { file_path } " )
61+ max_logging . log (f"Successfully deleted file: { file_path } " )
6262 except OSError as e :
6363 # This catches other issues like permission errors
64- print (f"Error deleting file '{ file_path } ': { e } " )
64+ max_logging . log (f"Error deleting file '{ file_path } ': { e } " )
6565 else :
66- print (f"The file '{ file_path } ' does not exist." )
66+ max_logging . log (f"The file '{ file_path } ' does not exist." )
6767
6868jax .config .update ("jax_use_shardy_partitioner" , True )
6969
@@ -86,12 +86,14 @@ def inference_generate_video(config, pipeline, filename_prefix=""):
8686 guidance_scale = config .guidance_scale ,
8787 )
8888
89- print (f"video { filename_prefix } , compile time: { (time .perf_counter () - s0 )} " )
89+ max_logging . log (f"video { filename_prefix } , compile time: { (time .perf_counter () - s0 )} " )
9090 for i in range (len (videos )):
9191 video_path = f"{ filename_prefix } wan_output_{ config .seed } _{ i } .mp4"
9292 export_to_video (videos [i ], video_path , fps = config .fps )
93- upload_video_to_gcs (config .output_dir , video_path )
94- delete_file (f"./{ video_path } " )
93+ if config .output_dir .startswith ("gs://" ):
94+ upload_video_to_gcs (config .output_dir , video_path )
95+ # Delete local files to avoid storing too manys videoss
96+ delete_file (f"./{ video_path } " )
9597 return
9698
9799def run (config , pipeline = None , filename_prefix = "" ):
@@ -128,7 +130,8 @@ def run(config, pipeline=None, filename_prefix=""):
128130 video_path = os .path .join (f"{ filename_prefix } wan_output_{ config .seed } _{ i } .mp4" )
129131 export_to_video (videos [i ], video_path , fps = config .fps )
130132 saved_video_path .append (video_path )
131- upload_video_to_gcs (config .output_dir , video_path )
133+ if config .output_dir .startswith ("gs://" ):
134+ upload_video_to_gcs (config .output_dir , video_path )
132135
133136 s0 = time .perf_counter ()
134137 videos = pipeline (
0 commit comments