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

Use CRDS sync instead of informal URL for HST reffile downloads #53

Merged
merged 4 commits into from
Mar 8, 2022

Conversation

stsci-hack
Copy link
Contributor

This update replaces use of an informal URL and website with calls to CRDS for downloading HST reference files. It is a 'transparent' replacement in that there are no API changes and no changes in behavior from the previous implementation.

@stsci-hack stsci-hack added the enhancement New feature or request label Mar 8, 2022
@stsci-hack stsci-hack requested review from nden and pllim March 8, 2022 19:39
@stsci-hack stsci-hack self-assigned this Mar 8, 2022
@stsci-hack
Copy link
Contributor Author

This PR will NOT be ready for merging until all the tests actually pass. Working on it now...

@@ -108,6 +116,8 @@ def download_crds(refname, timeout=30, verbose=False):

"""
refdir = None
fname = refname
print('Deprecation Warning: `timeout` parameter no longer needed.')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bit brute force to print this regardless. You could change the signature to take **kwargs and only emit warning if timeout is given. Also better to use warnings.warn(..., DeprecationWarning).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. Coming right up...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to using 'warnings.warn' in e00d94c

from ci_watson.artifactory_helpers import check_url, _download
# need to insure CRDS has been cached locally
os.environ['CRDS_SERVER_URL'] = CRDS_SERVER_URL
os.environ['CRDS_PATH']='./'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you ever run the test locally, is this behavior desirable? Won't this download a bunch of stuff into the working dir?

Copy link
Contributor Author

@stsci-hack stsci-hack Mar 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, that is the point of using the 'crds sync' call below; namely, only those files which are requested get downloaded whether it is local or remote. I ran this on my Windows system at home and only downloaded the one reference file that was requested without getting any other CRDS file. These definitions, though, are required in order to tell CRDS what server to use and that it should only download the files into the local directory (to start with anyway). I could, though, make this definition dependent on whether or not it was already defined by the user. Would that be safer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was made in b68f309. It was also tested on my desktop Linux workstation at work (freyja) and when 'iref' was defined to point to the local directory, it only copied the desired reference file as requested, while it did not copy anything when 'iref' was pointing to the already available local online cache (as before). It also still works just fine under Windows as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does hstcal even run on Windows? 👀

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just don't want to get into the situation where dev runs this locally, downloads a bunch of files into the working dir (which might be source dir), and then accidentally git add all of them into version control.

make this definition dependent on whether or not it was already defined by the user. Would that be safer?

Yes, I think so.

Copy link
Contributor Author

@stsci-hack stsci-hack Mar 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My tests have been run primarily on Drizzlepac under Windows, not hstcal, as I have not tried to build hstcal C code under Windows. This definition of the URL was made optional under b68f309 and worked as expected only downloading the requested single reference file on my STScI Linux desktop system.

@pllim

This comment was marked as resolved.

@stsci-hack
Copy link
Contributor Author

Actually, this package is perfectly compatible with Windows, since I developed and tested this change on my home Windows PC.

@stsci-hack stsci-hack requested a review from pllim March 8, 2022 20:10
Copy link
Collaborator

@pllim pllim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works for you, then great. Though you might want to test this out downstream before merge... You can open a PR downstream to use ci-watson from this PR branch.

@stsci-hack
Copy link
Contributor Author

This change allowed the Drizzlepac pytest 'hap/test_pipeline.py' test to pass as before when run interactively (under Windows) without downloading any extra files. The same test run interactively under Linux also worked as expected.

@stsci-hack stsci-hack merged commit 57df821 into spacetelescope:master Mar 8, 2022
@stsci-hack stsci-hack deleted the use_crds_for_hst branch March 8, 2022 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants