Update mix python script for new log format (#53)
* Update mix python script for new log format * remove unused imports
This commit is contained in:
parent
9740035f85
commit
c600ebd304
|
@ -1,17 +1,12 @@
|
||||||
# !/usr/bin/env python
|
# !/usr/bin/env python
|
||||||
|
import argparse
|
||||||
import json
|
import json
|
||||||
import sys
|
import statistics
|
||||||
from collections.abc import Iterable
|
from collections.abc import Iterable
|
||||||
from typing import Dict, Optional
|
from typing import Dict, Optional
|
||||||
import statistics
|
|
||||||
import argparse
|
|
||||||
|
|
||||||
import mixlog
|
import mixlog
|
||||||
|
|
||||||
from json_stream.base import TransientStreamingJSONObject
|
|
||||||
|
|
||||||
JsonStream = Iterable[TransientStreamingJSONObject]
|
|
||||||
|
|
||||||
|
|
||||||
class Message:
|
class Message:
|
||||||
def __init__(self, message_id: str, step_a: Optional[int]):
|
def __init__(self, message_id: str, step_a: Optional[int]):
|
||||||
|
@ -73,8 +68,13 @@ def parse_record_stream(record_stream: Iterable[str]) -> MessageStorage:
|
||||||
storage: MessageStorage = {}
|
storage: MessageStorage = {}
|
||||||
|
|
||||||
for record in record_stream:
|
for record in record_stream:
|
||||||
json_record = json.loads(record)
|
try:
|
||||||
payload_id = json_record["payload_id"]
|
json_record = json.loads(record)
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if (payload_id := json_record.get("payload_id")) is None:
|
||||||
|
continue
|
||||||
step_id = json_record["step_id"]
|
step_id = json_record["step_id"]
|
||||||
|
|
||||||
if (stored_message := storage.get(payload_id)) is None:
|
if (stored_message := storage.get(payload_id)) is None:
|
||||||
|
@ -91,12 +91,12 @@ def build_argument_parser() -> argparse.ArgumentParser:
|
||||||
"--step-duration",
|
"--step-duration",
|
||||||
type=int,
|
type=int,
|
||||||
default=100,
|
default=100,
|
||||||
help="Duration (in ms) of each step in the simulation."
|
help="Duration (in ms) of each step in the simulation.",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"input_file",
|
"input_file",
|
||||||
nargs="?",
|
nargs="?",
|
||||||
help="The file to parse. If not provided, input will be read from stdin."
|
help="The file to parse. If not provided, input will be read from stdin.",
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue