From 5645e3132e2cf763376440acfbc1ff75fec8e0c6 Mon Sep 17 00:00:00 2001 From: Future-Outlier Date: Tue, 29 Oct 2024 23:24:20 +0800 Subject: [PATCH 1/4] Gate feature by checking backend version Signed-off-by: Future-Outlier --- flytekit/clients/friendly.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flytekit/clients/friendly.py b/flytekit/clients/friendly.py index 72875f84f7..c255c2c4b5 100644 --- a/flytekit/clients/friendly.py +++ b/flytekit/clients/friendly.py @@ -11,6 +11,7 @@ from flyteidl.admin import project_pb2 as _project_pb2 from flyteidl.admin import task_execution_pb2 as _task_execution_pb2 from flyteidl.admin import task_pb2 as _task_pb2 +from flyteidl.admin import version_pb2 as _version_pb2 from flyteidl.admin import workflow_attributes_pb2 as _workflow_attributes_pb2 from flyteidl.admin import workflow_pb2 as _workflow_pb2 from flyteidl.core import identifier_pb2 as _identifier_pb2 @@ -1087,3 +1088,7 @@ def get_download_artifact_signed_url( expires_in=expires_in_pb, ) ) + + def get_control_plane_version(self) -> str: + version_response = self._stub.GetVersion(_version_pb2.GetVersionRequest(), metadata=self._metadata) + return version_response.control_plane_version.Version From de6eea3f134c415c515e6917645b2c6c37ea4168 Mon Sep 17 00:00:00 2001 From: Future-Outlier Date: Wed, 30 Oct 2024 09:56:06 +0800 Subject: [PATCH 2/4] put context in comments or in serialization settings Signed-off-by: Future-Outlier --- flytekit/clis/sdk_in_container/pyflyte.py | 1 + 1 file changed, 1 insertion(+) diff --git a/flytekit/clis/sdk_in_container/pyflyte.py b/flytekit/clis/sdk_in_container/pyflyte.py index a492e1cba8..5d00c179df 100644 --- a/flytekit/clis/sdk_in_container/pyflyte.py +++ b/flytekit/clis/sdk_in_container/pyflyte.py @@ -56,6 +56,7 @@ ) @click.pass_context def main(ctx, pkgs: typing.List[str], config: str, verbose: int): + # TODO: put context here """ Entrypoint for all the user commands. """ From 5f112c99006e408c84d5d0a2e54912465780d4da Mon Sep 17 00:00:00 2001 From: Future-Outlier Date: Wed, 30 Oct 2024 23:20:14 +0800 Subject: [PATCH 3/4] get control plane version and add integration tests Signed-off-by: Future-Outlier --- flytekit/clis/sdk_in_container/pyflyte.py | 1 - tests/flytekit/integration/remote/test_remote.py | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/flytekit/clis/sdk_in_container/pyflyte.py b/flytekit/clis/sdk_in_container/pyflyte.py index 5d00c179df..a492e1cba8 100644 --- a/flytekit/clis/sdk_in_container/pyflyte.py +++ b/flytekit/clis/sdk_in_container/pyflyte.py @@ -56,7 +56,6 @@ ) @click.pass_context def main(ctx, pkgs: typing.List[str], config: str, verbose: int): - # TODO: put context here """ Entrypoint for all the user commands. """ diff --git a/tests/flytekit/integration/remote/test_remote.py b/tests/flytekit/integration/remote/test_remote.py index 4d77e1b610..ee4573c011 100644 --- a/tests/flytekit/integration/remote/test_remote.py +++ b/tests/flytekit/integration/remote/test_remote.py @@ -762,3 +762,8 @@ def test_register_wf_fast(register): def test_fetch_active_launchplan_not_found(register): remote = FlyteRemote(Config.auto(config_file=CONFIG), PROJECT, DOMAIN) assert remote.fetch_active_launchplan(name="basic.list_float_wf.fake_wf") is None + +def test_get_control_plane_version(): + client = _SynchronousFlyteClient(PlatformConfig.for_endpoint("localhost:30080", True)) + version = client.get_control_plane_version() + assert version == "unknown" or version.startswith("v") From 5d67ee93a3d78d30b228d196f305b08c37d9249a Mon Sep 17 00:00:00 2001 From: Future-Outlier Date: Thu, 31 Oct 2024 10:23:51 +0800 Subject: [PATCH 4/4] Update Kevin's advice Signed-off-by: Future-Outlier --- flytekit/clients/friendly.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/flytekit/clients/friendly.py b/flytekit/clients/friendly.py index c255c2c4b5..f506960f82 100644 --- a/flytekit/clients/friendly.py +++ b/flytekit/clients/friendly.py @@ -1090,5 +1090,14 @@ def get_download_artifact_signed_url( ) def get_control_plane_version(self) -> str: + """ + Retrieve the Control Plane version from Flyteadmin. + + This method calls Flyteadmin's GetVersion API to obtain the current version information of the control plane. + The retrieved version can be used to enable or disable specific features based on the Flyteadmin version. + + Returns: + str: The version string of the control plane. + """ version_response = self._stub.GetVersion(_version_pb2.GetVersionRequest(), metadata=self._metadata) return version_response.control_plane_version.Version