Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robust Username Masking in print_config #6922

Merged
merged 1 commit into from
Aug 31, 2023
Merged
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
12 changes: 3 additions & 9 deletions monai/config/deviceconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from __future__ import annotations

import getpass
import os
import platform
import re
Expand Down Expand Up @@ -100,15 +101,8 @@
print(f"{k} version: {v}", file=file, flush=True)
print(f"MONAI flags: HAS_EXT = {HAS_EXT}, USE_COMPILED = {USE_COMPILED}, USE_META_DICT = {USE_META_DICT}")
print(f"MONAI rev id: {monai.__revision_id__}")
masked_file_path = re.sub(
r"/home/\w+/",
"/home/<username>/",
re.sub(
r"/Users/\w+/",
"/Users/<username>/",
re.sub(r"C:\\Users\\\w+\\", r"C:\\Users\\<username>\\", monai.__file__),
),
)
username = getpass.getuser()
masked_file_path = re.sub(username, "<username>", monai.__file__)

Check warning on line 105 in monai/config/deviceconfig.py

View check run for this annotation

Codecov / codecov/patch

monai/config/deviceconfig.py#L104-L105

Added lines #L104 - L105 were not covered by tests
print(f"MONAI __file__: {masked_file_path}", file=file, flush=True)
print("\nOptional dependencies:", file=file, flush=True)
for k, v in get_optional_config_values().items():
Expand Down
Loading