From 440dc3acd393ba925cbd42975fe7a2133ef1c1ad Mon Sep 17 00:00:00 2001 From: Future-Outlier Date: Mon, 1 Jul 2024 15:55:31 -0700 Subject: [PATCH] Fix `Flytefile` Remote Path Error (#2544) * print messages for sandbox execute and local execute Signed-off-by: Future-Outlier * remove PR 2476 change Signed-off-by: Future-Outlier * print execution mode in flytefile Signed-off-by: Future-Outlier * add should upload Signed-off-by: Future-Outlier * add condition ctx.execution_state.mode != ExecutionState.Mode.TASK_EXECUTION Signed-off-by: Future-Outlier * bug found, need to call the function Signed-off-by: Future-Outlier * remove comparison Signed-off-by: Future-Outlier * use ctx.execution_state.is_local_execution() Signed-off-by: Future-Outlier * lint Signed-off-by: Future-Outlier * fix bug Signed-off-by: Future-Outlier * remove comments Signed-off-by: Future-Outlier * revert is_local_execution Signed-off-by: Future-Outlier --------- Signed-off-by: Future-Outlier Signed-off-by: Jan Fiedler --- flytekit/core/context_manager.py | 2 +- flytekit/types/file/file.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flytekit/core/context_manager.py b/flytekit/core/context_manager.py index c51b60c1c9..506e55c829 100644 --- a/flytekit/core/context_manager.py +++ b/flytekit/core/context_manager.py @@ -547,7 +547,7 @@ def with_params( user_space_params=user_space_params if user_space_params else self.user_space_params, ) - def is_local_execution(self): + def is_local_execution(self) -> bool: return ( self.mode == ExecutionState.Mode.LOCAL_TASK_EXECUTION or self.mode == ExecutionState.Mode.LOCAL_WORKFLOW_EXECUTION diff --git a/flytekit/types/file/file.py b/flytekit/types/file/file.py index 567b29de57..5304fd21ed 100644 --- a/flytekit/types/file/file.py +++ b/flytekit/types/file/file.py @@ -440,7 +440,7 @@ def to_literal( # Set the remote destination if one was given instead of triggering a random one below remote_path = python_val.remote_path or None - if ctx.execution_state.is_local_execution and python_val.remote_path is None: + if ctx.execution_state.is_local_execution() and python_val.remote_path is None: should_upload = False elif isinstance(python_val, pathlib.Path) or isinstance(python_val, str): @@ -458,7 +458,7 @@ def to_literal( p = pathlib.Path(python_val) if not p.is_file(): raise TypeTransformerFailedError(f"Error converting {python_val} because it's not a file.") - if ctx.execution_state.is_local_execution: + if ctx.execution_state.is_local_execution(): should_upload = False # python_type must be os.PathLike - see check at beginning of function else: