44import os
55import csv
66import pandas as pd
7- import logging
87from fastapi import APIRouter , Body , Response , Request
98from fastapi .responses import StreamingResponse , FileResponse
109
@@ -169,7 +168,7 @@ async def get_tasks_job_output(job_id: str, sweeps: bool = False):
169168 try :
170169 job_data = json .loads (job_data )
171170 except JSONDecodeError :
172- logging . error (f"Error decoding job_data for job { job_id } . Using empty job_data." )
171+ print (f"Error decoding job_data for job { job_id } . Using empty job_data." )
173172 job_data = {}
174173
175174 # Handle sweeps case first
@@ -198,7 +197,7 @@ async def get_tasks_job_output(job_id: str, sweeps: bool = False):
198197 # If the value error starts with "No output file found for job" then wait 4 seconds and try again
199198 # because the file might not have been created yet
200199 if str (e ).startswith ("No output file found for job" ):
201- logging . info (f"Output file not found for job { job_id } , retrying in 4 seconds..." )
200+ print (f"Output file not found for job { job_id } , retrying in 4 seconds..." )
202201 await asyncio .sleep (4 )
203202 try :
204203 output_file_name = await shared .get_job_output_file_name (job_id )
@@ -212,7 +211,7 @@ async def get_tasks_job_output(job_id: str, sweeps: bool = False):
212211 return ["Output file not found after retry" ]
213212 except Exception as retry_e :
214213 # If still no file after retry, create an empty one in the jobs directory
215- logging . warning (
214+ print (
216215 f"Still no output file found for job { job_id } after retry, creating empty file: { retry_e } "
217216 )
218217 # Use the Job class to get the proper directory and create the file
@@ -223,11 +222,11 @@ async def get_tasks_job_output(job_id: str, sweeps: bool = False):
223222 f .write ("" )
224223 return []
225224 else :
226- logging . error (f"ValueError in get_tasks_job_output: { e } " )
225+ print (f"ValueError in get_tasks_job_output: { e } " )
227226 return ["An internal error has occurred!" ]
228227 except Exception as e :
229228 # Handle general error
230- logging . error (f"Error in get_tasks_job_output: { e } " )
229+ print (f"Error in get_tasks_job_output: { e } " )
231230 return ["An internal error has occurred!" ]
232231
233232
@@ -252,10 +251,10 @@ async def update_training_template(
252251 datasets = configObject ["dataset_name" ]
253252 job_service .update_training_template (template_id , name , description , type , datasets , config )
254253 except JSONDecodeError as e :
255- logging . error (f"JSON decode error: { e } " )
254+ print (f"JSON decode error: { e } " )
256255 return {"status" : "error" , "message" : "An error occurred while processing the request." }
257256 except Exception as e :
258- logging . error (f"Unexpected error: { e } " )
257+ print (f"Unexpected error: { e } " )
259258 return {"status" : "error" , "message" : "An internal error has occurred." }
260259 return {"status" : "success" }
261260
@@ -276,7 +275,7 @@ async def stream_job_output(job_id: str, sweeps: bool = False):
276275 try :
277276 job_data = json .loads (job_data )
278277 except JSONDecodeError :
279- logging . error (f"Error decoding job_data for job { job_id } . Using empty job_data." )
278+ print (f"Error decoding job_data for job { job_id } . Using empty job_data." )
280279 job_data = {}
281280
282281 # Handle sweeps case first
@@ -295,13 +294,13 @@ async def stream_job_output(job_id: str, sweeps: bool = False):
295294 # If the value error starts with "No output file found for job" then wait 4 seconds and try again
296295 # because the file might not have been created yet
297296 if str (e ).startswith ("No output file found for job" ):
298- logging . info (f"Output file not found for job { job_id } , retrying in 4 seconds..." )
297+ print (f"Output file not found for job { job_id } , retrying in 4 seconds..." )
299298 await asyncio .sleep (4 )
300299 try :
301300 output_file_name = await shared .get_job_output_file_name (job_id )
302301 except Exception as retry_e :
303302 # If still no file after retry, create an empty one in the jobs directory
304- logging . warning (
303+ print (
305304 f"Still no output file found for job { job_id } after retry, creating empty file: { retry_e } "
306305 )
307306 # Use the Job class to get the proper directory and create the file
@@ -311,15 +310,15 @@ async def stream_job_output(job_id: str, sweeps: bool = False):
311310 with open (output_file_name , "w" ) as f :
312311 f .write ("" )
313312 else :
314- logging . error (f"ValueError in stream_job_output: { e } " )
313+ print (f"ValueError in stream_job_output: { e } " )
315314 return StreamingResponse (
316315 iter (["data: Error: An internal error has occurred!\n \n " ]),
317316 media_type = "text/event-stream" ,
318317 headers = {"Cache-Control" : "no-cache" , "Connection" : "keep-alive" , "Access-Control-Allow-Origin" : "*" },
319318 )
320319 except Exception as e :
321320 # Handle general error
322- logging . error (f"Error in stream_job_output: { e } " )
321+ print (f"Error in stream_job_output: { e } " )
323322 return StreamingResponse (
324323 iter (["data: Error: An internal error has occurred!\n \n " ]),
325324 media_type = "text/event-stream" ,
@@ -461,7 +460,7 @@ async def get_eval_images(job_id: str):
461460 }
462461 )
463462 except OSError as e :
464- logging . error (f"Error reading images directory { images_dir } : { e } " )
463+ print (f"Error reading images directory { images_dir } : { e } " )
465464 return {"images" : []}
466465
467466 # Sort by filename for consistent ordering
@@ -625,7 +624,7 @@ async def get_checkpoints(job_id: str, request: Request):
625624 # Format the timestamp as ISO 8601 string
626625 formatted_time = datetime .fromtimestamp (modified_time ).isoformat ()
627626 except Exception as e :
628- logging . error (f"Error getting stat for file { file_path } : { e } " )
627+ print (f"Error getting stat for file { file_path } : { e } " )
629628 formatted_time = None
630629 filesize = None
631630 checkpoints .append ({"filename" : filename , "date" : formatted_time , "size" : filesize })
@@ -675,14 +674,14 @@ async def get_artifacts(job_id: str, request: Request):
675674 filename = os .path .basename (artifact_path )
676675 artifacts .append ({"filename" : filename , "date" : formatted_time , "size" : filesize })
677676 except Exception as e :
678- logging . error (f"Error getting stat for artifact { artifact_path } : { e } " )
677+ print (f"Error getting stat for artifact { artifact_path } : { e } " )
679678 continue
680679
681680 # Sort artifacts by filename in reverse (descending) order for consistent ordering
682681 artifacts .sort (key = lambda x : x ["filename" ], reverse = True )
683682 return {"artifacts" : artifacts }
684683 except Exception as e :
685- logging . info (f"SDK artifact method failed for job { job_id } , falling back to legacy method: { e } " )
684+ print (f"SDK artifact method failed for job { job_id } , falling back to legacy method: { e } " )
686685
687686 # Fallback to the original logic if SDK method doesn't work or returns nothing
688687 # Get artifacts directory from job_data or use default location
@@ -708,12 +707,12 @@ async def get_artifacts(job_id: str, request: Request):
708707 # Format the timestamp as ISO 8601 string
709708 formatted_time = datetime .fromtimestamp (modified_time ).isoformat ()
710709 except Exception as e :
711- logging . error (f"Error getting stat for file { file_path } : { e } " )
710+ print (f"Error getting stat for file { file_path } : { e } " )
712711 formatted_time = None
713712 filesize = None
714713 artifacts .append ({"filename" : filename , "date" : formatted_time , "size" : filesize })
715714 except OSError as e :
716- logging . error (f"Error reading artifacts directory { artifacts_dir } : { e } " )
715+ print (f"Error reading artifacts directory { artifacts_dir } : { e } " )
717716
718717 # Sort artifacts by filename in reverse (descending) order for consistent ordering
719718 artifacts .sort (key = lambda x : x ["filename" ], reverse = True )
@@ -752,11 +751,11 @@ async def get_training_job_output_jobpath(job_id: str, sweeps: bool = False):
752751 return output
753752 except ValueError as e :
754753 # Handle specific error
755- logging . error (f"ValueError: { e } " )
754+ print (f"ValueError: { e } " )
756755 return "An internal error has occurred!"
757756 except Exception as e :
758757 # Handle general error
759- logging . error (f"Error: { e } " )
758+ print (f"Error: { e } " )
760759 return "An internal error has occurred!"
761760
762761
@@ -773,12 +772,12 @@ async def sweep_results(job_id: str):
773772 output = json .load (f )
774773 return {"status" : "success" , "data" : output }
775774 except json .JSONDecodeError as e :
776- logging . error (f"JSON decode error for job { job_id } : { e } " )
775+ print (f"JSON decode error for job { job_id } : { e } " )
777776 return {"status" : "error" , "message" : "Invalid JSON format in sweep results file." }
778777 else :
779- logging . warning (f"Sweep results file not found for job { job_id } : { output_file } " )
778+ print (f"Sweep results file not found for job { job_id } : { output_file } " )
780779 return {"status" : "error" , "message" : "Sweep results file not found." }
781780
782781 except Exception as e :
783- logging . error (f"Error loading sweep results for job { job_id } : { e } " )
782+ print (f"Error loading sweep results for job { job_id } : { e } " )
784783 return {"status" : "error" , "message" : "An internal error has occurred!" }
0 commit comments