You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@bsipocz I would like to start contributing to the project. This issue is regarding only data.py#L202 ? Or as part of the fix I should also search in other files for io.BytesIO? Thank you.
yes, I think the first approach would be to switch here only, but I'm cc-ing the io.fits and io.votable maintainers to comment whether they think it could be changed in those modules, too. (@pllim, @MSeifert04@saimn)
Let's leave io.votable alone for now. While there is explicit note in utils to switch away from BytesIO, it is not obviously so over in io.votable. @mdboom added that note in utils 5 years ago, so if he would like to chime in, then great; if not, my decision stands.
It could be interesting to have a look for similar cases in io.fits if you want to (there is one in file.py I think), but it's fine to start with only the current issue in utils - one thing after the other.
Currently, only the attribute read is checked (I didn't check other usages for utils.get_readable_fileobj), but in order to use io.BufferedReader the object should have the attribute readable, as io.FileIO objects have.
So, when the parameter name_or_obj of utils.get_readable_fileobj is an object, we need to make sure it has the readable attribute, otherwise io.BufferedReader will fail.
So I guess we would need to add the attribute readable to FakeStream (to fix the test) and ensure that the objects passed to utils.get_readable_fileobj also have this attribute, but since I am new to the project, I don't know what would be the impact of the latter in terms of changes in the rest of the codebase.
Could please tell me what to do now?
I am not experienced with file I/O in python, so if there's something I am missing, please let me know.
@jairideout , I don't see why not, though I would advise submitting one PR per sub-module. That is separate out, say utils changes from io.fits and so on. I also advise that you don't start with io.fits. 😄
An attempt at this , thanks to @jairideout , has made us realized that this battle is not worth fighting. We can revisit if there is a practical need in the future.
Activity
VitorFalcao commentedon Oct 5, 2017
@bsipocz I would like to start contributing to the project. This issue is regarding only data.py#L202 ? Or as part of the fix I should also search in other files for io.BytesIO? Thank you.
bsipocz commentedon Oct 5, 2017
yes, I think the first approach would be to switch here only, but I'm cc-ing the io.fits and io.votable maintainers to comment whether they think it could be changed in those modules, too. (@pllim, @MSeifert04 @saimn)
pllim commentedon Oct 6, 2017
Let's leave
io.votablealone for now. While there is explicit note inutilsto switch away fromBytesIO, it is not obviously so over inio.votable. @mdboom added that note inutils5 years ago, so if he would like to chime in, then great; if not, my decision stands.saimn commentedon Oct 6, 2017
It could be interesting to have a look for similar cases in
io.fitsif you want to (there is one infile.pyI think), but it's fine to start with only the current issue inutils- one thing after the other.VitorFalcao commentedon Oct 8, 2017
@bsipocz I was making the first change, starting with https://github.com/astropy/astropy/blob/master/astropy/utils/data.py#L202 and I did the following:
Then I executed
python3 setup.py test -P utilsand got the following error:Then I checked the test file and I saw that
FakeStreamhas areadattribute, but not areadable:astropy/astropy/utils/tests/test_data.py
Lines 375 to 403 in 308ea8f
So I thought I would need to change the test only. But, I decided to check how the method
utils.get_readable_fileobjis used and I saw this:astropy/astropy/io/ascii/core.py
Lines 289 to 295 in 308ea8f
Currently, only the attribute
readis checked (I didn't check other usages forutils.get_readable_fileobj), but in order to useio.BufferedReaderthe object should have the attributereadable, asio.FileIOobjects have.So, when the parameter
name_or_objofutils.get_readable_fileobjis an object, we need to make sure it has thereadableattribute, otherwiseio.BufferedReaderwill fail.So I guess we would need to add the attribute
readabletoFakeStream(to fix the test) and ensure that the objects passed toutils.get_readable_fileobjalso have this attribute, but since I am new to the project, I don't know what would be the impact of the latter in terms of changes in the rest of the codebase.Could please tell me what to do now?
I am not experienced with file I/O in python, so if there's something I am missing, please let me know.
jairideout commentedon Oct 24, 2018
I'm interested in working on this issue if it isn't actively being worked on. Is it okay for me to move forward with it? Thanks!
pllim commentedon Oct 25, 2018
@jairideout , I don't see why not, though I would advise submitting one PR per sub-module. That is separate out, say
utilschanges fromio.fitsand so on. I also advise that you don't start withio.fits. 😄jairideout commentedon Oct 25, 2018
Thanks for the guidance @pllim! I'll get started on this soon, with a separate PR per sub-module.
Use BufferedReader instead of BytesIO in `utils` subpackage
jairideout commentedon Oct 26, 2018
@pllim I submitted a PR (#7981) to update the
utilssubpackage to useBufferedReaderinstead ofBytesIO.pllim commentedon Oct 26, 2018
I'll review when I get a chance. Thank you very much!
pllim commentedon May 25, 2019
An attempt at this , thanks to @jairideout , has made us realized that this battle is not worth fighting. We can revisit if there is a practical need in the future.