Skip to content

Commit

Permalink
Merge pull request #21 from mlcommons/et_jsonizer
Browse files Browse the repository at this point in the history
et_jsonizer: Refactor et_jsonizer
  • Loading branch information
srinivas212 authored Feb 7, 2024
2 parents 120ce3d + a78aee9 commit e3a0677
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions utils/et_jsonizer/et_jsonizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,31 @@

def main() -> None:
parser = argparse.ArgumentParser(
description="Execution Trace Jsonizer"
description="Converts Chakra execution trace to JSON format."
)
parser.add_argument(
"--input_filename",
type=str,
default=None,
required=True,
help="Input Chakra execution trace filename"
help="Specifies the input filename of the Chakra execution trace."
)
parser.add_argument(
"--output_filename",
type=str,
default=None,
required=True,
help="Output filename"
help="Specifies the output filename for the JSON data."
)
args = parser.parse_args()

et = open_file_rd(args.input_filename)
execution_trace = open_file_rd(args.input_filename)
node = ChakraNode()
with open(args.output_filename, 'w') as f:
gm = GlobalMetadata()
decode_message(et, gm)
f.write(MessageToJson(gm))
while decode_message(et, node):
f.write(MessageToJson(node))
et.close()
with open(args.output_filename, 'w') as file:
global_metadata = GlobalMetadata()
decode_message(execution_trace, global_metadata)
file.write(MessageToJson(global_metadata))
while decode_message(execution_trace, node):
file.write(MessageToJson(node))
execution_trace.close()


if __name__ == "__main__":
Expand Down

0 comments on commit e3a0677

Please sign in to comment.