From ab97d5708dbc4e5d7e77aa8ef7a53b836d1f5ed2 Mon Sep 17 00:00:00 2001 From: Alexey Volkov Date: Tue, 4 Jun 2019 17:57:53 -0700 Subject: [PATCH] SDK - Only install cloudpickle if it's not available (#1434) This makes unit tests much faster. Also: Pined the version to 1.1.1. Made the installation quiet. --- sdk/python/kfp/components/_python_op.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sdk/python/kfp/components/_python_op.py b/sdk/python/kfp/components/_python_op.py index 9dd4522417b..08fd5cef88d 100644 --- a/sdk/python/kfp/components/_python_op.py +++ b/sdk/python/kfp/components/_python_op.py @@ -58,9 +58,12 @@ def _capture_function_code_using_cloudpickle(func) -> str: func_code = '{func_name} = pickle.loads({func_pickle})'.format(func_name=func.__name__, func_pickle=repr(func_pickle)) code_lines = [ - 'import subprocess', - 'import sys', - 'subprocess.call([sys.executable, "-m", "pip", "install", "cloudpickle"])' + 'try:', + ' import cloudpickle as _cloudpickle', + 'except ImportError:', + ' import subprocess', + ' import sys', + ' subprocess.call([sys.executable, "-m", "pip", "install", "cloudpickle==1.1.1", "--quiet"])' '', 'import pickle', '',