Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions argoverse/utils/sim2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import json
import os
from pathlib import Path
from typing import Union

import numpy as np
Expand Down Expand Up @@ -153,6 +154,9 @@ def save_as_json(self, save_fpath: _PathLike) -> None:
Args:
save_fpath: path to where json file should be saved
"""
if not Path(save_fpath).exists():
Copy link
Copy Markdown
Contributor

@benjaminrwilson benjaminrwilson Jul 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jlambert,

Thanks for adding this. I notice that this function calls save_json_dict. Do you think that it might be convenient if we move directory creation into that function?

My thought is this: https://github.com/argoai/argoverse-api/blob/9ad7251e863590603c3f6064a45830dabd3a15e2/argoverse/utils/json_utils.py#L32 could be modified as:

json_fpath = Path(json_fpath)
json_fpath.parent.mkdir(parents=True, exist_ok=True)
with json_fpath.open("w") as f:
    json.dump(dictionary, f)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on this.

os.makedirs(Path(save_fpath).parent, exist_ok=True)

dict_for_serialization = {
"R": self.rotation.flatten().tolist(),
"t": self.translation.flatten().tolist(),
Expand Down