Skip to content

Commit

Permalink
SDK/Lightweight - Added python version compatibility checks
Browse files Browse the repository at this point in the history
See my compatibility analysis: cloudpipe/cloudpickle#293
  • Loading branch information
Ark-kun committed Jun 18, 2019
1 parent 660419a commit 9b02539
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion sdk/python/kfp/components/_python_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,23 @@ def _capture_function_code_using_cloudpickle(func, modules_to_capture: List[str]
import cloudpickle as _cloudpickle
print("cloudpickle loaded successfully after installing.", file=sys.stderr)
pickler_python_version = {pickler_python_version}
current_python_version = tuple(sys.version_info)
if current_python_version[0] != pickler_python_version[0] or current_python_version[0] == 3 and pickler_python_version[1] < 6 and current_python_version[1] >= 6:
raise RuntimeError("Incompatible python versions: " + str(current_python_version) + " instead of " + str(pickler_python_version))
if current_python_version != pickler_python_version:
print("Warning: Different python versions. The code may crash. Versions: " + str(current_python_version) + " instead of " + str(pickler_python_version), file=sys.stderr)
import base64
import pickle
{func_name} = pickle.loads(base64.b64decode({func_pickle}))
'''.format(func_name=func.__name__, func_pickle=repr(func_pickle))
'''.format(
func_name=func.__name__,
func_pickle=repr(func_pickle),
pickler_python_version=repr(tuple(sys.version_info)),
)

return function_loading_code

Expand Down

0 comments on commit 9b02539

Please sign in to comment.