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

Revert "Remove soon-to-be-deprecated usage of AsdfFile.open" #2858

Merged
merged 1 commit into from
Nov 9, 2018

Conversation

jdavies-st
Copy link
Collaborator

Reverts #2814

@jdavies-st
Copy link
Collaborator Author

So while #2814 passed our regression tests, it turns out that if you try to read a file that is read-only:

In [2]: a = asdf.open('/grp/crds/cache/references/jwst/jwst_nircam_specwcs_0010.asdf')                                                                          
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
<ipython-input-2-753b8171a465> in <module>
----> 1 a = asdf.open('/grp/crds/cache/references/jwst/jwst_nircam_specwcs_0010.asdf')

~/miniconda3/envs/jwst_dev/lib/python3.7/site-packages/asdf/asdf.py in open_asdf(fd, uri, mode, validate_checksums, extensions, do_not_fill_defaults, ignore_version_mismatch, ignore_unrecognized_tag, _force_raw_types, copy_arrays, lazy_load, custom_schema, strict_extension_check, ignore_missing_extensions, _compat)
   1357         _force_raw_types=_force_raw_types,
   1358         strict_extension_check=strict_extension_check,
-> 1359         ignore_missing_extensions=ignore_missing_extensions)
   1360 
   1361 

~/miniconda3/envs/jwst_dev/lib/python3.7/site-packages/asdf/asdf.py in _open_impl(cls, self, fd, uri, mode, validate_checksums, do_not_fill_defaults, _get_yaml_content, _force_raw_types, strict_extension_check, ignore_missing_extensions)
    711                 _force_raw_types=_force_raw_types,
    712                 strict_extension_check=strict_extension_check,
--> 713                 ignore_missing_extensions=ignore_missing_extensions)
    714 
    715     @classmethod

~/miniconda3/envs/jwst_dev/lib/python3.7/site-packages/asdf/asdf.py in _open_asdf(cls, self, fd, uri, mode, validate_checksums, do_not_fill_defaults, _get_yaml_content, _force_raw_types, strict_extension_check, ignore_missing_extensions)
    608         self._mode = mode
    609 
--> 610         fd = generic_io.get_file(fd, mode=self._mode, uri=uri)
    611         self._fd = fd
    612         # The filename is currently only used for tracing warning information

~/miniconda3/envs/jwst_dev/lib/python3.7/site-packages/asdf/generic_io.py in get_file(init, mode, uri, close)
   1188                 fd = atomicfile.atomic_open(realpath, realmode)
   1189             else:
-> 1190                 fd = open(realpath, realmode)
   1191             fd = fd.__enter__()
   1192             return RealFile(fd, mode, close=True, uri=uri)

PermissionError: [Errno 13] Permission denied: '/grp/crds/cache/references/jwst/jwst_nircam_specwcs_0010.asdf'

You get an error. You have to specify when opening that it is to be read in read-only mode now:

In [3]: a = asdf.open('/grp/crds/cache/references/jwst/jwst_nircam_specwcs_0010.asdf', mode='r')                                                                

@jdavies-st
Copy link
Collaborator Author

What I expect this means is that we have to expose the mode='r' or mode='rw' ASDF API in datamodels. We should probably revert this PR for now, and discuss the best way forward next week.

@jdavies-st
Copy link
Collaborator Author

Of course the other option is to ask asdf to not default to mode='rw', but I don't know what is involved there. Anyway, let's get this reverted and sort it out next week.

@nden nden merged commit e6c4fed into master Nov 9, 2018
@jdavies-st jdavies-st deleted the revert-2814-asdf-deprecation branch December 7, 2018 16:51
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