Skip to content

[MRG] Solve part of 'Remove fixes/compat for Python 2' #11991 #15231

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

Closed
wants to merge 1 commit into from

Conversation

sbehren
Copy link
Contributor

@sbehren sbehren commented Oct 13, 2019

Reference Issues/PRs

Solves part of #11991

What does this implement/fix? Explain your changes.

The function
sklearn.datasets.base._pkl_filepath
is a compatibility function for Python 2 support.

The function expects path components as *args and constructs and returns the path to a pickel from it.

It modifies the last path component as follows:

  • For Python 3, it adds a suffix ('_py3' by default, or the value of the kwarg 'py3_suffix' if specified).
  • For Python 2, it does nothing .
    It then concatenates its arguments using os.path.join and returns the
    result.

If Python 2 support is to be deprecated, we can

  • remove the function _pkl_filepath and
  • replace all calls to it by direct calls to os.path.join,
    as done in this MR.

Any other comments?

The function
sklearn.datasets.base._pkl_filepath
is a compatibility function for Python 2 support.

The function expects path components as *args and constructs and returns the path to a pickel from it.

It modifies the last path component as follows:
- For Python 3, it adds a suffix ('_py3' by default, or the value of the kwarg 'py3_suffix' if specified).
- For Python 2, it does nothing .
It then concatenates its arguments using os.path.join and returns the
result.

If Python 2 support is to be deprecated, we can
- remove the function _pkl_filepath and
- replace all calls to it by direct calls to os.path.join.
@sbehren sbehren changed the title [MRG] This addresses part of 'Remove fixes/compat for Python 2' #11991 [MRG] Solve part of 'Remove fixes/compat for Python 2' #11991 Oct 13, 2019
@sbehren
Copy link
Contributor Author

sbehren commented Oct 13, 2019

I am quite sure that my changes should not affect the code coverage of the code sections reported by the tool. Could this be a glitch on the codecov side?

@rth
Copy link
Member

rth commented Oct 13, 2019

The issue is that users may still have Python 2 pickles in their cache.
So while we can get rid of this logic, the pickle path should be that used previously for Python 3 (i.e. with a '_py3') suffix (otherwise users may get errors).

So if we want to remove that function, we need to manually change all the file paths that use it to include the suffix.

@rth
Copy link
Member

rth commented Oct 13, 2019

I am quite sure that my changes should not affect the code coverage of the code sections reported by the tool.

Well, you removed a function which was covered in tests so the total coverage decreased slightly, that's fine, don't worry about it.

@sbehren sbehren closed this Oct 13, 2019
@sbehren
Copy link
Contributor Author

sbehren commented Oct 13, 2019

Will revert changes in new PR.

@rth
Copy link
Member

rth commented Oct 13, 2019

@sbehren better to add them in this one. You can just push additional commits and change the PR title as need. It make it much easier for reviewers to follow what is going on.

@sbehren
Copy link
Contributor Author

sbehren commented Oct 13, 2019

@sbehren better to add them in this one. You can just push additional commits and change the PR title as need. It make it much easier for reviewers to follow what is going on.

Thanks for the info, will do!

@sbehren
Copy link
Contributor Author

sbehren commented Oct 13, 2019

I force-pushed my changes to my old branch. This prevents me from reopening this MR. I did not know this, sorry @rth

@rth
Copy link
Member

rth commented Oct 13, 2019

I force-pushed my changes to my old branch. This prevents me from reopening this MR. I

Hmm, I didn't know that either. Force pushing in an open PR works fine (though it's better to avoid force pushing and adding commits instead in any case). Please ping me in the other PR that you open.

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.

2 participants