Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixing unsuccessful checks.

Signed-off-by: staydelight <[email protected]>
  • Loading branch information
staydelight committed Jun 3, 2024
1 parent ea2866b commit f70de5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions monai/transforms/io/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

from __future__ import annotations

import json
import inspect
import json
import logging
import sys
import traceback
Expand Down Expand Up @@ -394,7 +394,7 @@ def __init__(
output_name_formatter: Callable[[dict, Transform], dict] | None = None,
folder_layout: FolderLayoutBase | None = None,
savepath_in_metadict: bool = False,
mapping_json_path: Path | str | None = None
mapping_json_path: Path | str | None = None,
) -> None:
self.folder_layout: FolderLayoutBase
if folder_layout is None:
Expand Down Expand Up @@ -515,18 +515,17 @@ def __call__(
meta_data["saved_to"] = filename
if self.mapping_json_path and meta_data is not None:
log_data = []
log_data.append({
"input": meta_data.get("filename_or_obj", ()),
"output": meta_data.get("saved_to", ())
})
log_data.append(
{"input": meta_data.get("filename_or_obj", ()), "output": meta_data.get("saved_to", ())}
)

try:
with open(self.mapping_json_path) as f:
existing_log_data = json.load(f)
except FileNotFoundError:
existing_log_data = []

with open(self.mapping_json_path, 'w') as f:
with open(self.mapping_json_path, "w") as f:
existing_log_data.extend(log_data)
json.dump(existing_log_data, f, indent=4)
return img
Expand Down
4 changes: 2 additions & 2 deletions monai/transforms/io/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def __init__(
output_name_formatter: Callable[[dict, Transform], dict] | None = None,
folder_layout: monai.data.FolderLayoutBase | None = None,
savepath_in_metadict: bool = False,
mapping_json_path: Path | str | None = None
mapping_json_path: Path | str | None = None,
) -> None:
super().__init__(keys, allow_missing_keys)
self.meta_keys = ensure_tuple_rep(meta_keys, len(self.keys))
Expand All @@ -305,7 +305,7 @@ def __init__(
output_name_formatter=output_name_formatter,
folder_layout=folder_layout,
savepath_in_metadict=savepath_in_metadict,
mapping_json_path= mapping_json_path,
mapping_json_path=mapping_json_path,
)

def set_options(self, init_kwargs=None, data_kwargs=None, meta_kwargs=None, write_kwargs=None):
Expand Down

0 comments on commit f70de5b

Please sign in to comment.