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

Remove and deprecate unused functions #444

Closed
wants to merge 10 commits into from

Conversation

jrbourbeau
Copy link
Member

From what I can tell it appears these functions aren't used anywhere and the test suite has coverage for Tornado coroutines, Ellipsis, and NotImplemented.

def test_Ellipsis(self):
self.assertEqual(Ellipsis,
pickle_depickle(Ellipsis, protocol=self.protocol))
def test_NotImplemented(self):
ExcClone = pickle_depickle(NotImplemented, protocol=self.protocol)
self.assertEqual(NotImplemented, ExcClone)

def test_EllipsisType(self):
res = pickle_depickle(type(Ellipsis), protocol=self.protocol)
self.assertEqual(type(Ellipsis), res)
def test_NotImplementedType(self):
res = pickle_depickle(type(NotImplemented), protocol=self.protocol)
self.assertEqual(type(NotImplemented), res)

def test_tornado_coroutine(self):

This PR proposes we remove these unused functions, though do let me know if I'm missing something and these utilities are in fact needed for some external code paths.

@codecov
Copy link

codecov bot commented Sep 11, 2021

Codecov Report

Merging #444 (d9ffb4f) into master (fca7b22) will decrease coverage by 2.67%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #444      +/-   ##
==========================================
- Coverage   92.36%   89.68%   -2.68%     
==========================================
  Files           4        4              
  Lines         720      698      -22     
  Branches      150      147       -3     
==========================================
- Hits          665      626      -39     
- Misses         34       62      +28     
+ Partials       21       10      -11     
Impacted Files Coverage Δ
cloudpickle/cloudpickle.py 82.96% <66.66%> (-5.35%) ⬇️
cloudpickle/__init__.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fca7b22...d9ffb4f. Read the comment docs.

Copy link
Contributor

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

Probably a left over of a previous refactoring. +1 for cleaning up.

@pierreglaser any opinion?

@pierreglaser
Copy link
Member

So, I believe that _rebuild_tornado_corutine, and the _gen_ functions may be used to re-build pickles containing tornado coroutines, or NotImplemented etc... created using older versions of cloudpickle. Maybe worth adding a small deprecation cycle, as we did for _make_skel_func for instance?

By the way, _make_skel_func can be now removed, since we're past the end of its deprecation cycle 1.7.0.

As for is_tornado_coroutine, I guess this is semi-public, and I'm not sure whether we have been consistent in handling the removal of such functions. My guess is that we can remove it.

@jrbourbeau jrbourbeau changed the title Remove unused functions Remove and deprecate unused functions Sep 15, 2021
@jrbourbeau
Copy link
Member Author

jrbourbeau commented Sep 15, 2021

Maybe worth adding a small deprecation cycle, as we did for _make_skel_func for instance?

Thanks for the tip, I've added a deprecation message to these functions

By the way, _make_skel_func can be now removed, since we're past the end of its deprecation cycle 1.7.0.

Hmm this has caused several of the tests/test_backward_compat.py tests to start failing with

AttributeError: Can't get attribute '_make_skel_func' on <module 'cloudpickle.cloudpickle' from '/home/runner/work/cloudpickle/cloudpickle/cloudpickle/cloudpickle.py'>

It looks like there's a tests/generate_old_pickles.py script for generating the old pickle files used by these tests. I'm wondering what an appropriate "old" version of cloudpickle would be for these tests after removing _make_skel_func?

EDIT: Based on the deprecation message in _make_skel_func, perhaps we should regenerate the static test files using cloudpickle 1.5.0?

@pierreglaser
Copy link
Member

pierreglaser commented Sep 15, 2021

EDIT: Based on the deprecation message in _make_skel_func, perhaps we should regenerate the static test files using cloudpickle 1.5.0?

Yes. The pickles that we generate using cloudpickle 1.5.0 should not rely on _make_skel_func, regenerating the pickles should work :)

@jrbourbeau jrbourbeau changed the title Remove and deprecate unused functions [WIP] Remove and deprecate unused functions Sep 22, 2021
Copy link
Member Author

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

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

Alright, @pierreglaser I think this is ready for another look. Recent commits added a GitHub actions workflow to help automatically generate the static pickle files used in tests/test_backward_compat.py and upload them as GitHub actions artifacts. This will hopefully make it easier to regenerate them in the future.

That said, I'm not sure how often this will be needed. We may want to comment out the workflow to avoid it running on each PR and just uncomment it when needed. Alternatively, we could take an approach similar to the downstream CI builds

if: "contains(github.event.pull_request.labels.*.name, 'ci distributed') || contains(github.event.pull_request.labels.*.name, 'ci downstream')"

and add a "generate-pickles" label (or some other name) to determine when the workflow is run. No strong opinion from me one way or the other.

# pickles files generated with cloudpickle_fast.py on old versions of
# coudpickle with Python < 3.8 use non-deprecated reconstructors.
check_deprecation_warning = (sys.version_info < (3, 8))
def load_obj(filename, check_deprecation_warning=False):
Copy link
Member Author

Choose a reason for hiding this comment

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

Since _make_skel_func has been removed we no longer raise a warning in most cases for the tests in this module. Because of this I decided to change check_deprecation_warning to be False by default, so checking deprecation warnings will need to be done explicitly. Happy to try something else out though

@jrbourbeau jrbourbeau changed the title [WIP] Remove and deprecate unused functions Remove and deprecate unused functions Sep 23, 2021
@pierreglaser pierreglaser self-requested a review September 24, 2021 10:38
Copy link
Contributor

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

This PR still @lgtm besides the following minor point.

@pierreglaser and second review?

@@ -0,0 +1,46 @@
name: Generate static pickle files

on: pull_request
Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, I think we should not run this at each PR. Let's use a manual trigger instead: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow

Copy link
Member

@pierreglaser pierreglaser left a comment

Choose a reason for hiding this comment

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

Thanks @jrbourbeau. @ogrisel manually triggering the pickle generation workflow sounds good to me. I just have one question on the current way artifacts are stored across workflows.

cd ../

- name: Upload pickle files
uses: actions/upload-artifact@v2
Copy link
Member

Choose a reason for hiding this comment

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

IIUC, Storing pickles as artifacts implies that these pickles will only be available for 90 days (see https://github.com/actions/upload-artifact#retention-period), so we need maintainers to re-run this workflow every 90 days. Are people fine with it? @ogrisel @jrbourbeau

@ogrisel
Copy link
Contributor

ogrisel commented Oct 13, 2023

Closing now that #517 was merged with similar changes and further simplification (because of the drop of Python 3.6 and 3.7 support).

@ogrisel ogrisel closed this Oct 13, 2023
@ogrisel
Copy link
Contributor

ogrisel commented Oct 13, 2023

Actually this PR also add the automation for the generation of old pickle files while in #517 I checked them into the git repo.

@jrbourbeau / @pierreglaser feel free to reopen a PR with that change if you prefer the automated way of dealing with this.

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.

3 participants