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

[BEAM-8123] Add cloudpickle as optional library #15472

Merged
merged 60 commits into from Dec 1, 2021

Conversation

ryanthompson591
Copy link
Contributor

@ryanthompson591 ryanthompson591 commented Sep 7, 2021

Wraps the pickle library so that users can choose either cloudpickle or dill.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

ValidatesRunner compliance status (on master branch)

Lang ULR Dataflow Flink Samza Spark Twister2
Go --- Build Status Build Status Build Status Build Status ---
Java Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Python --- Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status ---
XLang Build Status Build Status Build Status Build Status Build Status ---

Examples testing status on various runners

Lang ULR Dataflow Flink Samza Spark Twister2
Go --- --- --- --- --- --- ---
Java --- Build Status
Build Status
Build Status
--- --- --- --- ---
Python --- --- --- --- --- --- ---
XLang --- --- --- --- --- --- ---

Post-Commit SDK/Transform Integration Tests Status (on master branch)

Go Java Python
Build Status Build Status Build Status
Build Status
Build Status

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website Whitespace Typescript
Non-portable Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status Build Status Build Status
Portable --- Build Status Build Status --- --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

See CI.md for more information about GitHub Actions CI.

@ryanthompson591 ryanthompson591 changed the title wrapped pickler so that pickler is chosen Add cloudpickle as optional library Oct 29, 2021
@ryanthompson591
Copy link
Contributor Author

R: @tvalentyn

@ryanthompson591
Copy link
Contributor Author

Python Unit Tests

@ryanthompson591
Copy link
Contributor Author

Python Unit Tests

@ryanthompson591
Copy link
Contributor Author

Python Unit Tests

@ryanthompson591
Copy link
Contributor Author

Python Unit Tests

sdks/python/apache_beam/coders/coders_test_common.py Outdated Show resolved Hide resolved
sdks/python/apache_beam/internal/cloudpickle_pickler.py Outdated Show resolved Hide resolved
loads(dumps(module_test.TopClass.MiddleClass.NestedClass('abc'))).datum)

def test_dynamic_class(self):
"""Tests that a nested class object is pickled correctly."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: duplicated comment?

You could also name the test so that it captures the behavior; then the comment becomes unnecessary. E.g. smth like:

test_pickling_preserves_closure_of_a_function()
test_dynamic_class_objects_pickle_correctly()


def change_pickle_lib(pickle_lib):
""" Changes pickling library. Users should prefer the default library."""
global pickler_lib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. how about we use desired_pickler instead of pickle_lib to avoid possible confusion due to a typo?
  2. It seems like the condition below should be inverted.
  3. Let's change the function to: set_pickle_lib to avoid confusion with a usage that inverts a current value without taking desired value into account.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I like these suggestions.

@tvalentyn
Copy link
Contributor

I think Run Unit Tests is not a valid trigger command, tests run by themselves when you push new changes. Github action tests don't have trigger commands, but could be re-triggered by via a UI. Jenkins suites have trigger commands listed in quotes and also in https://github.com/apache/beam/blob/master/.test-infra/jenkins/README.md . There is also "retestt this please" command that reruns all Jenkins suites (typo intentional to avoid actual re-test as I type this).

@tvalentyn
Copy link
Contributor

Looks like there are a few errors in the suites:

2:32:13 > Task :sdks:python:test-suites:portable:py36:portableWordCountFlinkRunnerBatch FAILED
12:32:13 Traceback (most recent call last):
12:32:13   File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
12:32:13     mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
12:32:13   File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
12:32:13     __import__(pkg_name)
12:32:13   File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_Portable_Python_Commit/src/build/gradleenv/2022703440/lib/python3.6/site-packages/apache_beam/__init__.py", line 90, in <module>
12:32:13     import apache_beam.internal.pickler
12:32:13   File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_Portable_Python_Commit/src/build/gradleenv/2022703440/lib/python3.6/site-packages/apache_beam/internal/pickler.py", line 31, in <module>
12:32:13     from apache_beam.internal import cloudpickle_pickler
12:32:13   File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_Portable_Python_Commit/src/build/gradleenv/2022703440/lib/python3.6/site-packages/apache_beam/internal/cloudpickle_pickler.py", line 49, in <module>
12:32:13     import cloudpickle
12:32:13 ModuleNotFoundError: No module named 'cloudpickle'

For this one, you need to add a dependency on cloudpickle in setup.py

@@ -26,6 +26,7 @@
# TODO(AVRO-2429): Upgrade to >= 1.9.0 only after resolved
avro-python3==1.8.2
fastavro==1.0.0.post1
cloudpickle=2.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs == instead of = (see Docker suite failure).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha. That's why it was failing. Done.

CHANGES.md Outdated Show resolved Hide resolved
@@ -68,7 +69,7 @@ google-cloud-videointelligence==1.16.1
google-cloud-vision==1.0.0
google-crc32c==1.3.0
google-pasta==0.2.0
google-python-cloud-debugger==2.18
google-python-cloud-debugger==2.8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this an accidental manual change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah there is something weird going on here. I've manually changed this PR to only add cloudpickle. It shouldn't be doing anything else.

@tvalentyn tvalentyn merged commit bf9b959 into apache:master Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants