Skip to content

Commit ccc2364

Browse files
use isfile
Signed-off-by: Yiheng Wang <vennw@nvidia.com>
1 parent 3fbe598 commit ccc2364

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

monai/bundle/workflows.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@ def __init__(
8484
raise ValueError(f"Unsupported workflow type: '{workflow_type}'.")
8585

8686
if logging_file is not None:
87-
if not os.path.exists(logging_file):
87+
if not os.path.isfile(logging_file):
8888
raise FileNotFoundError(f"Cannot find the logging config file: {logging_file}.")
8989
logger.info(f"Setting logging properties based on config: {logging_file}.")
9090
fileConfig(logging_file, disable_existing_loggers=False)
9191

9292
if meta_file is not None:
93-
if isinstance(meta_file, str) and not os.path.exists(meta_file):
93+
if isinstance(meta_file, str) and not os.path.isfile(meta_file):
9494
raise FileNotFoundError(f"Cannot find the metadata config file: {meta_file}.")
9595
if isinstance(meta_file, list):
9696
for f in meta_file:
97-
if not os.path.exists(f):
97+
if not os.path.isfile(f):
9898
raise FileNotFoundError(f"Cannot find the metadata config file: {f}.")
9999

100100
self.meta_file = meta_file
@@ -276,7 +276,7 @@ def __init__(
276276

277277
logging_file = str(self.config_root_path / "logging.conf") if logging_file is None else logging_file
278278
if logging_file is not None:
279-
if not os.path.exists(logging_file):
279+
if not os.path.isfile(logging_file):
280280
if logging_file == str(self.config_root_path / "logging.conf"):
281281
logger.warn(f"Default logging file in {logging_file} does not exist, skipping logging.")
282282
else:
@@ -288,14 +288,14 @@ def __init__(
288288
self.parser = ConfigParser()
289289
self.parser.read_config(f=config_file)
290290
meta_file = str(self.config_root_path / "metadata.json") if meta_file is None else meta_file
291-
if isinstance(meta_file, str) and not os.path.exists(meta_file):
291+
if isinstance(meta_file, str) and not os.path.isfile(meta_file):
292292
logger.error(
293293
f"Cannot find the metadata config file: {meta_file}. "
294294
"Please see: https://docs.monai.io/en/stable/mb_specification.html"
295295
)
296296
elif isinstance(meta_file, list):
297297
for f in meta_file:
298-
if not os.path.exists(f):
298+
if not os.path.isfile(f):
299299
logger.error(
300300
f"Cannot find the metadata config file: {f}. "
301301
"Please see: https://docs.monai.io/en/stable/mb_specification.html"

0 commit comments

Comments
 (0)