Skip to content

Commit edf2e9e

Browse files
committed
add config file checks
Signed-off-by: luarss <[email protected]>
1 parent 86a1e15 commit edf2e9e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tools/AutoTuner/src/autotuner/distributed.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,12 @@ def read_tune_ax(name, this):
290290
dict_["value_type"] = "float"
291291
return dict_
292292

293-
with open(file_name) as file:
294-
data = json.load(file)
293+
# Check file exists and whether it is a valid JSON file.
294+
assert os.path.isfile(file_name), f'File {file_name} not found.'
295+
try:
296+
with open(file_name) as file: data = json.load(file)
297+
except json.JSONDecodeError:
298+
raise ValueError(f"Invalid JSON file: {file_name}")
295299
sdc_file = ''
296300
fr_file = ''
297301
if args.mode == 'tune' and args.algorithm == 'ax':

0 commit comments

Comments
 (0)