This repository was archived by the owner on Jun 3, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +21
-14
lines changed
src/sparseml/pytorch/utils Expand file tree Collapse file tree 3 files changed +21
-14
lines changed Original file line number Diff line number Diff line change 4848from sparseml .utils import ALL_TOKEN , create_dirs
4949
5050
51+ _LOGGER = logging .getLogger (__name__ )
52+
53+
5154__all__ = [
5255 "BaseLogger" ,
5356 "LambdaLogger" ,
@@ -332,11 +335,21 @@ def __init__(
332335 self ._logger = logger
333336 else :
334337 self ._logger = logging .getLogger (__name__ )
338+
339+ base_log_path = (
340+ os .environ .get ("NM_TEST_LOG_DIR" )
341+ if os .environ .get ("NM_TEST_MODE" )
342+ else "sparse_logs"
343+ )
335344 now = datetime .now ()
336345 dt_string = now .strftime ("%d-%m-%Y_%H.%M.%S" )
337- os .makedirs ("sparse_logs" , exist_ok = True )
346+ log_path = os .path .join (base_log_path , f"{ dt_string } .log" )
347+ os .makedirs (base_log_path , exist_ok = True )
348+
349+ _LOGGER .info (f"Logging all SparseML modifier-level logs to { log_path } " )
350+
338351 handler = logging .FileHandler (
339- os . path . join ( "sparse_logs" , f" { dt_string } .log" ) ,
352+ log_path ,
340353 delay = True ,
341354 )
342355 self ._logger .addHandler (handler )
Original file line number Diff line number Diff line change 2525
2626
2727os .environ ["NM_TEST_MODE" ] = "True"
28- os .environ ["NM_TEST_LOG_DIR" ] = "temp_test_logs "
28+ os .environ ["NM_TEST_LOG_DIR" ] = "nm_temp_test_logs "
2929
3030
3131@pytest .fixture (scope = "session" , autouse = True )
@@ -35,14 +35,8 @@ def check_for_created_files():
3535 if wandb :
3636 wandb .finish ()
3737 log_dir = os .environ .get ("NM_TEST_LOG_DIR" )
38- log_dir_tensorboard = os .path .join (log_dir , "tensorboard" )
39- log_dir_wandb = os .path .join (log_dir , "wandb" )
40- if os .path .isdir (log_dir_tensorboard ):
41- shutil .rmtree (log_dir_tensorboard )
42- if os .path .isdir (log_dir_wandb ):
43- shutil .rmtree (log_dir_wandb )
44- if os .path .isdir (log_dir ) and len (os .listdir (log_dir )) == 0 :
45- os .rmdir (log_dir )
38+ if os .path .isdir (log_dir ):
39+ shutil .rmtree (log_dir )
4640 end_file_count = sum (len (files ) for _ , _ , files in os .walk (r"." ))
4741 assert (
4842 start_file_count >= end_file_count
Original file line number Diff line number Diff line change 2020# Ignore submodules
2121collect_ignore_glob = ["tensorflow_v1-onnx/*" ]
2222
23-
24- FAILURE_LOG = "test_logs/ failures.log"
23+ LOG_DIR = os . environ [ "NM_TEST_LOG_DIR" ] or "test_logs"
24+ FAILURE_LOG = os . path . join ( LOG_DIR , " failures.log")
2525
2626
2727def pytest_configure (config ):
2828 if os .path .exists (FAILURE_LOG ):
2929 os .remove (FAILURE_LOG )
30- os .makedirs ("test_logs" , exist_ok = True )
30+ os .makedirs (LOG_DIR , exist_ok = True )
3131
3232
3333def write_to_failure_log (node_id , long_repr ):
You can’t perform that action at this time.
0 commit comments