From 9d3c0873b4acf7f20353a8f88ded42849a94eb51 Mon Sep 17 00:00:00 2001 From: Anish Rajan Date: Fri, 1 Sep 2023 02:01:31 +0530 Subject: [PATCH] robust username masking in print_config --- monai/config/deviceconfig.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/monai/config/deviceconfig.py b/monai/config/deviceconfig.py index 023eb8bfd39..a4580c741bc 100644 --- a/monai/config/deviceconfig.py +++ b/monai/config/deviceconfig.py @@ -11,6 +11,7 @@ from __future__ import annotations +import getpass import os import platform import re @@ -100,15 +101,8 @@ def print_config(file=sys.stdout): 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//", - re.sub( - r"/Users/\w+/", - "/Users//", - re.sub(r"C:\\Users\\\w+\\", r"C:\\Users\\\\", monai.__file__), - ), - ) + username = getpass.getuser() + masked_file_path = re.sub(username, "", monai.__file__) 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():