Skip to content

Commit

Permalink
orchestration/experiment_output: fix key order in output JSON
Browse files Browse the repository at this point in the history
This removes automatically sorting the keys that I introduced in #97, which means that instead, attributes are serialized in the order they are defined in. With this change, simple information like start and end time are readable at a glance directly at the top of the JSON file.
  • Loading branch information
jonas-kaufmann authored and FreakyPenguin committed May 11, 2024
1 parent 132d7a9 commit 135e711
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class ExpOutput(object):

def __init__(self, exp: Experiment) -> None:
self.exp_name = exp.name
self.metadata = exp.metadata
self.start_time = None
self.end_time = None
self.sims: tp.Dict[str, tp.Dict[str, tp.Union[str, tp.List[str]]]] = {}
self.success = True
self.interrupted = False
self.metadata = exp.metadata
self.sims: tp.Dict[str, tp.Dict[str, tp.Union[str, tp.List[str]]]] = {}

def set_start(self) -> None:
self.start_time = time.time()
Expand Down Expand Up @@ -70,7 +70,7 @@ def add_sim(
def dump(self, outpath: str) -> None:
pathlib.Path(outpath).parent.mkdir(parents=True, exist_ok=True)
with open(outpath, 'w', encoding='utf-8') as file:
json.dump(self.__dict__, file, sort_keys=True, indent=4)
json.dump(self.__dict__, file, indent=4)

def load(self, file: str) -> None:
with open(file, 'r', encoding='utf-8') as fp:
Expand Down

0 comments on commit 135e711

Please sign in to comment.