99
1010"""
1111import os
12+ import logging
1213import argparse
1314from datetime import datetime
1415import tempfile
@@ -61,7 +62,10 @@ def health_check():
6162 # setup logging
6263 utils .setup_logging (log_file = args .logfile , log_level = args .loglevel , cli_extra = args .logextra )
6364
65+ logger = logging .getLogger (__name__ )
66+
6467 print (f"Running RJM health check v{ __version__ } ..." )
68+ logger .debug (f"Running RJM health check v{ __version__ } ..." )
6569
6670 with tempfile .TemporaryDirectory () as tmpdir :
6771 # create remote job object
@@ -74,9 +78,11 @@ def health_check():
7478 prefix = f"health-check-{ datetime .now ().strftime ('%Y%m%dT%H%M%S' )} "
7579 print ()
7680 print ("Testing creation of unique remote directory (this could take up to a couple of minutes)..." )
81+ logger .debug ("Testing creation of unique remote directory..." )
7782 rj .make_remote_directory (prefix = prefix , retries = args .retries )
7883 remote_dir = rj .get_remote_directory ()
7984 print (f'Created remote directory: "{ remote_dir } "' )
85+ logger .debug (f'Created remote directory: "{ remote_dir } "' )
8086
8187 # write file to local directory
8288 test_file_name = "test.txt"
@@ -87,21 +93,27 @@ def health_check():
8793 # upload that file
8894 print ()
8995 print ("Testing uploading a file..." )
96+ logger .debug ("Testing uploading a file..." )
9097 t .upload_files ([test_file_local ]) # this function always does retries
9198 print ("Finished testing uploading a file" )
99+ logger .debug ("Finished testing uploading a file" )
92100
93101 # use runner to check the directory and file exists (tests funcx)
94102 print ()
95103 print ("Using runner to check directory and file exist..." )
104+ logger .debug ("Using runner to check directory and file exist..." )
96105 run_function = r .run_function_with_retries if args .retries else r .run_function
97106 result = run_function (_remote_health_check , remote_dir , test_file_name , args .keep )
98107 if result is None :
99108 print ("Finished checking directory and file exist" )
109+ logger .debug ("Finished checking directory and file exist" )
100110 else :
111+ logger .error (f"Error checking directory and file exist: { result } " )
101112 raise RuntimeError (f"Error checking directory and file exist: { result } " )
102113
103114 print ()
104115 print ("If there were no errors above it looks like basic functionality is good" )
116+ logger .debug ("If there were no errors above it looks like basic functionality is good" )
105117 print ()
106118
107119
0 commit comments