-
Notifications
You must be signed in to change notification settings - Fork 3
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
tweak/enhance auto data install #50
base: develop
Are you sure you want to change the base?
Conversation
hmm, a side issue in this: I was hoping to use the recently-added standard library Mostly I would like to avoid unnecessary effort writing our own deprecation warning machinery -- this very much feels like something we should be able to get from upstream somewhere. Let me think about an alternative way to do that... |
OK, I think it will work to, in
and I think that works, based on some testing here. And, no particular deprecation warning is needed in this case, because it'll be covered under the overall deprecation warning at the top of webbpsf. |
get_webbpsf_data_path will not actually be used once webbpsf2.0.0 is released. Webbpsf will directly call get_stpsf_data_path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
installation.rst changes are great
Please undo the utils.py changes for reasons in the comment
|
||
Files containing such information as the JWST pupil shape, instrument throughputs, and aperture positions are distributed separately from STPSF. To run STPSF, you must download these files and tell STPSF where to find them using the ``STPSF_PATH`` environment variable. | ||
STPSF will now **automatically download and install these files** the first time it is run. By default these will be downloaded and installed into a folder ``$HOME/data/stpsf-data`` within the user's home directory. This directory will be created automatically if it doesn't exist already. If this path is acceptable to you, then no further action is needed on your part, and it'll all work automatically. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good addition! Thanks for cleaning up the docs!
path = auto_download_stpsf_data() | ||
|
||
# Check if the data were already downloaded to the default path | ||
default_path = get_default_data_path() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change isn't necessary as this logic already exists within auto_download_stpsf_data
(which also sets the STPSF_PATH which is necessary)
auto_download_stpsf_data()
will make a new default directory (only if one doesn't exist), and download the data (only if the directory is empty).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point here was intentionally refactoring to allow checking for a prior successful call to auto_download_stpsf_data, prior to displaying the big giant warning message about trying to download the data. If the data has already been downloaded successfully, it’s incorrect to display a warning that says “stpsf will try to download the data”.
The current code will display the warning text every time the package is imported in a new Python session, even if the data is already indeed present and fine in the default directory. That’s excess warnings for no benefit to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your concern (deleted my previous reply because I misunderstood what download message you were referring to)
I think its important that the Environment variable $STPSF_PATH is not set!
warning is still displayed.
May just make more sense to move the MISSING_STPSF_DATA_MESSAGE
inside auto_download_stpsf_data
inside the if not any(default_path.iterdir()):
codeblock.
My point is about existing user code that calls that function directly. That function is currently part of the public API of webbpsf, and I know for a fact there are existing notebooks and downstream scripts that call it directly. Not a lot but nonzero. I completely agree that all the internal code you updated to call get_stpsf_data_path. But again I’m trying to make sure we don’t break some existing notebooks or script that calls get_webbpsf_data_path directly. |
AH! Yes thats a good call. Overlooked that we should verify there are no other public API calls that specifically have "webbpsf" as part of the naming convention. (just confirmed that its only auto_download_webbpsf_data and get_webbpsf_data_path) |
Some enhancements building on the very nice data installation function added in spacetelescope/webbpsf#932 by @WilliamJamieson :
auto_download_stpsf_data
, then there's no need to emit any warning, just use that automatically installed data.get_webbpsf_data_dir
which is a deprecated equivalent forget_stpsf_data_dir
. This is simply to allow any existing webbpsf user code that callswebbpsf.utils.get_webbpsf_data_dir()
to continue to work without error. The deprecation is marked using the recently-added standard library@deprecated
decorator, or the back ported equivalent depending on Python version.