From f22cec205314ea2699560ae188dc866c87dd33b2 Mon Sep 17 00:00:00 2001 From: Austin Liu Date: Tue, 9 Jan 2024 04:21:31 +0800 Subject: [PATCH] add fs path exists checking (fix flyteorg/flyte#4470) (#2079) Signed-off-by: Austin Liu --- flytekit/core/data_persistence.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flytekit/core/data_persistence.py b/flytekit/core/data_persistence.py index d1651e8548..1579ef3f6b 100644 --- a/flytekit/core/data_persistence.py +++ b/flytekit/core/data_persistence.py @@ -33,7 +33,7 @@ from flytekit.configuration import DataConfig from flytekit.core.local_fsspec import FlyteLocalFileSystem from flytekit.core.utils import timeit -from flytekit.exceptions.user import FlyteAssertion +from flytekit.exceptions.user import FlyteAssertion, FlyteValueException from flytekit.interfaces.random import random from flytekit.loggers import logger @@ -254,6 +254,8 @@ def get(self, from_path: str, to_path: str, recursive: bool = False, **kwargs): return to_path except OSError as oe: logger.debug(f"Error in getting {from_path} to {to_path} rec {recursive} {oe}") + if not file_system.exists(from_path): + raise FlyteValueException(from_path, "File not found") file_system = self.get_filesystem(get_protocol(from_path), anonymous=True) if file_system is not None: logger.debug(f"Attempting anonymous get with {file_system}")