-
-
Notifications
You must be signed in to change notification settings - Fork 26.6k
MNT remove __file__ and use importlib.resource instead #20150
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
Conversation
… into solve_20081
… into solve_20081
|
Hi @nithish08, thanks for your pull request. A number of tests are failing with error It seems like the code tries to open a directory not a file... Could you please have a look? Thanks! |
|
Hi @cmarmo, I am unsure of how to solve this error. Can you please point me in the right direction? |
|
Run the tests locally and check which tests are failing and debug your code.
You will be able to reproduce the error that is shown on our continuous
integration.
…On Mon, 7 Jun 2021 at 19:44, Nithish Bolleddula ***@***.***> wrote:
Hi @cmarmo <https://github.com/cmarmo>, I am unsure of how to solve this
error. Can you please point me in the right direction?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20150 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABY32PYRT5BLV2KVD2DUTNLTRUAO7ANCNFSM45U27MBQ>
.
--
Guillaume Lemaitre
Scikit-learn @ Inria Foundation
https://glemaitre.github.io/
|
Hi @nithish08 , apparently importlib.resources.path need to open a file not a directory. So you need to point it to a file then cut the directory path. from os.path import join, dirname
with resources.path('sklearn.datasets', '__init__.py') as f:
module_path = dirname(f)
data, target, target_names = load_data(module_path, 'iris.csv')
iris_csv_filename = join(module_path, 'data', 'iris.csv')is working even if I'm not sure is totally correct... |
|
Maybe the code snippet proposed by @cmarmo could be factorized into a small private helper function if it needs to be repeated in many places of the scikit-learn code base. |
|
Hi, hope you don't mind me chiming in here. I am a little curious about what the purpose of replacing I have done a similar refactor for another project before but solely for the purpose of enabling the codespace as a zip executable archive ( |
|
@nithish08 I see that this is still open. Are you planning on continuing working on this? Or can I give it a go? |
|
@jackzyliu that's a valid concern. It would be interesting to see if we could use This would make it possible to use the scikit-learn dataset when scikit-learn is embedded in a PyOxidizer-generated binary for instance as @rth commented in #20081 (comment). This would mean changing the |
@ogrisel @rth I completely agree. I was doing a version aimed to be compatible with A slightly thorny issue is that functions like Edit: Just put up PR #20297 for discussion. @nithish08 @quendee feel free to chime in and/or apply similar changes to other files. |
I would rather not add a dependency. Instead write code that uses |
|
@quendee Please work on this issue if you would like to. |
|
@nithish08 I think @jackzyliu is working on this following @ogrisel suggestion. |
|
closing in favor of #20297 |
Fixes #20081
This PR removes the usage of file.