Skip to content

Commit 45c389f

Browse files
FindHaofacebook-github-bot
authored andcommitted
Refactor file mapping cleanup in parse_logs function (#102)
Summary: - Updated the cleanup logic in the `parse_logs` function to use `items()` for iterating over `file_mapping`, improving readability. - Simplified the removal of duplicates from `regular_files` and the deletion of `mapped_file` when it is `None`. These changes enhance code clarity and maintainability without altering the existing functionality. Pull Request resolved: #102 Reviewed By: sfzhu93 Differential Revision: D82337211 Pulled By: FindHao fbshipit-source-id: 9529de0962d8619717a36c4604cd0ae520cbf6aa
1 parent 1203104 commit 45c389f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tritonparse/common.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,15 +357,13 @@ def parse_logs(
357357
file_mapping[rank_key]["mapped_file"] = mapped_file
358358

359359
# Clean up the file mapping - remove None mapped_files and ensure no duplicates
360-
for rank_key in file_mapping:
360+
for rank_key, rank_data in file_mapping.items():
361361
if rank_key != "tritonparse_url_prefix":
362362
# Remove duplicates from regular_files
363-
file_mapping[rank_key]["regular_files"] = list(
364-
set(file_mapping[rank_key]["regular_files"])
365-
)
363+
rank_data["regular_files"] = list(set(rank_data["regular_files"]))
366364
# Remove mapped_file if None
367-
if file_mapping[rank_key]["mapped_file"] is None:
368-
del file_mapping[rank_key]["mapped_file"]
365+
if rank_data["mapped_file"] is None:
366+
del rank_data["mapped_file"]
369367
# Save file mapping to parsed_log_dir
370368
log_file_list_path = os.path.join(parsed_log_dir, "log_file_list.json")
371369
with open(log_file_list_path, "w") as f:

0 commit comments

Comments
 (0)