From 823960c29491cb8b2965a55671cfeac4109fc15d Mon Sep 17 00:00:00 2001 From: Yee Hing Tong Date: Fri, 5 Aug 2022 16:40:09 -0700 Subject: [PATCH] set to remote when dealing with remote files Signed-off-by: Yee Hing Tong --- flytekit/clis/sdk_in_container/run.py | 2 +- tests/flytekit/unit/cli/pyflyte/test_run.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/flytekit/clis/sdk_in_container/run.py b/flytekit/clis/sdk_in_container/run.py index 6fece1e7d2..95533fb4d5 100644 --- a/flytekit/clis/sdk_in_container/run.py +++ b/flytekit/clis/sdk_in_container/run.py @@ -88,7 +88,7 @@ def convert( self, value: typing.Any, param: typing.Optional[click.Parameter], ctx: typing.Optional[click.Context] ) -> typing.Any: if FileAccessProvider.is_remote(value): - return FileParam(filepath=value) + return FileParam(filepath=value, local=False) p = pathlib.Path(value) if p.exists() and p.is_file(): return FileParam(filepath=str(p.resolve())) diff --git a/tests/flytekit/unit/cli/pyflyte/test_run.py b/tests/flytekit/unit/cli/pyflyte/test_run.py index 64681aea7e..34f28f00b6 100644 --- a/tests/flytekit/unit/cli/pyflyte/test_run.py +++ b/tests/flytekit/unit/cli/pyflyte/test_run.py @@ -8,7 +8,13 @@ from flytekit.clis.sdk_in_container import pyflyte from flytekit.clis.sdk_in_container.constants import CTX_CONFIG_FILE from flytekit.clis.sdk_in_container.helpers import FLYTE_REMOTE_INSTANCE_KEY -from flytekit.clis.sdk_in_container.run import REMOTE_FLAG_KEY, RUN_LEVEL_PARAMS_KEY, get_entities_in_file, run_command +from flytekit.clis.sdk_in_container.run import ( + REMOTE_FLAG_KEY, + RUN_LEVEL_PARAMS_KEY, + FileParamType, + get_entities_in_file, + run_command, +) from flytekit.configuration import Image, ImageConfig from flytekit.core.task import task @@ -241,3 +247,11 @@ def check_image(*args, **kwargs): mock_remote.register_script.side_effect = check_image run_command(mock_click_ctx, a)() + + +def test_file_param(): + m = mock.MagicMock() + l = FileParamType().convert(__file__, m, m) + assert l.local + r = FileParamType().convert("https://tmp/file", m, m) + assert r.local is False