Skip to content

Commit 3bde116

Browse files
committed
adds a way to write query-cc-mode reults as a json
This change provides more programmable way to query CC mode without dependency on drivers.
1 parent d1ec2cb commit 3bde116

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

cli/per_gpu.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,20 @@ def main_per_gpu(gpu, opts):
221221
return False
222222

223223
cc_mode = gpu.query_cc_mode()
224-
info(f"{gpu} CC mode is {cc_mode}")
224+
output_data = {
225+
"gpu_bdf": str(gpu.bdf),
226+
"cc_mode": cc_mode
227+
}
228+
print(json.dumps(output_data))
229+
230+
if opts.output_json_file:
231+
try:
232+
with open(opts.output_json_file, 'w') as f:
233+
json.dump(output_data, f, indent=4)
234+
info(f"CC mode query result written to {opts.output_json_file}")
235+
except IOError as e:
236+
error(f"Failed to write CC mode query result to {opts.output_json_file}: {e}")
237+
return False
225238

226239
if opts.output_json_file:
227240
output_data = {

0 commit comments

Comments
 (0)