Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict Python Version Mismatch between Pickled Object and Remote Envrionment #2848

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Mecoli1219
Copy link
Contributor

@Mecoli1219 Mecoli1219 commented Oct 21, 2024

Tracking Issues

flyteorg/flyte#5907

Why are the changes needed?

In the Jupyter Notebook environment, we are using cloudpickle to package the entity at the binary level. When we load the pickled object with a different Python version, it will throw an unexpected error. Therefore, we should restrict loading pickled objects with the mismatched Python version.

What changes were proposed in this pull request?

Let's assume the Python version for the pickled object is X.

  1. If we load it in a Python version smaller than X, it is possible to crash. Therefore, we need to handle loading exceptions.
  2. If we successfully load the object, we need to check whether the Python version is matched. I added a new metadata in the pickled object to store the Python version when pickling, and this will be used for validation after loading.
  3. Enable logging error messages when trying to extract the output from remote execution so that the user doesn't need to go to Console to get the error message.

How was this patch tested?

I set the Python version of Jupyter Notebook to 3.11 and built 3 images with different Python versions for remote execution, including 3.9, 3.11, and 3.12.

Setup process

Screenshots

  • Remote Python version = 3.12
    image
  • Remote Python version = 3.11
    image
  • Remote Python version = 3.9
    image

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Signed-off-by: Mecoli1219 <[email protected]>
@Mecoli1219
Copy link
Contributor Author

cc @thomasjpfan

Signed-off-by: Mecoli1219 <[email protected]>
Signed-off-by: Mecoli1219 <[email protected]>
Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 79.16667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 78.50%. Comparing base (3fc51af) to head (21ae75c).

Files with missing lines Patch % Lines
flytekit/core/python_auto_container.py 77.77% 2 Missing ⚠️
flytekit/remote/remote.py 85.71% 2 Missing ⚠️
flytekit/remote/executions.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2848       +/-   ##
===========================================
+ Coverage   45.53%   78.50%   +32.96%     
===========================================
  Files         196      196               
  Lines       20418    20462       +44     
  Branches     2647     2649        +2     
===========================================
+ Hits         9298    16064     +6766     
+ Misses      10658     3699     -6959     
- Partials      462      699      +237     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

1 participant