-
Notifications
You must be signed in to change notification settings - Fork 1.1k
obtain a dedicated API key for testing NREL psm3 #870
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
Comments
I'm up for taking care of this. @wholmgren is there a particular email address or convention that you keep parent accounts for pvlib-python? Otherwise I'll just use my own for this. |
Thanks @CameronTStark. We don't have an email address for this kind of thing, but we could create one. @lboeman is it trivial to make an email address like |
@wholmgren Yes, I went ahead and set that up. You should receive a test email at that address. |
So I've tired this out on my fork and got it working in a test build. The thing that I'm finding is that there seems to be a limited number of API requests we can do per some amount of time. If I run all the tests in test_psm3.py often the second one fails but if I run them individually they pass. For a test, I ran test_psm3.py through the CI with a single bare_linux build with 3.5, 3.6, 3.7 Python versions and only the 3.5 passed. I chose "rerun failed tests" and the 3.6 and 3.7 tests passed without me changing anything. The error I'm getting is: "OVER_RATE_LIMIT","You have exceeded your rate limit. Try again later or contact us at https://developer.nrel.gov/contact/ for assistance" This is the same error as before with just using DEMO_KEY I believe but other tests pass confirming that the API key is configured correctly. @kanderso-nrel or @mikofski do you know if there's a requests/minute limit for the NREL API? |
@CameronTStark The documentation does include rate-limiting, see here: https://developer.nrel.gov/docs/solar/nsrdb/psm3_data_download/#rate-limits
I've suspected for some time that the rate limits in practice are (much) stricter than what is documented there -- I've had code with explicit 5-second delays between API calls fail after just a few iterations, without having made any calls for several days. It's been on my to-do list to do more formal investigation and bring it up with the maintainers. As far as I know, there's not necessarily a way to avoid what you're seeing. If others know different, I'd love to be wrong about that! |
Thank you for the confirmation that I'm not crazy @kanderso-nrel. I took a few iterations to be sure of what I was seeing. To make the tests past consistently the only solutions that I can propose are to put 5 sec timers in front of every API call and/or cut down the number of API calls to the bare minimum. Both aren't reasons to be excited to be sure. I'm not sure even NREL whitelisting Azure IPs for a higher throughput would be a workable fix. Do you have any other suggestions? In looking at test_psm3.py some of the tests made me wonder if we were testing pvlib or the API server. Are there any API calls that could be removed to help the situation? |
Now that you mention it, this pattern could well be the issue:
Those could easily send more than one request per second. Maybe we should wrap the
If that doesn't work, here are two ideas, neither of which is nearly as good as understanding the API rate limits: The API response includes two relevant headers indicating rate limit usage:
Maybe useful for e.g. monkey-patching the network calls in
Click to expand pytest output
I've used a retry approach like this before when I wanted to bulk download data from the API and kept getting seemingly spurious timeouts:
|
Is your feature request related to a problem? Please describe.
came up in #866 see this comment but related to most PR and testing in general - due to NREL PSM3 throttle limits for the DEMO key the CI's frequently fail
Describe the solution you'd like
obtain a dedicated API key from NREL developer network and upload it to Azure pipelines as a secret variable, ditto for Travis, then for testing, get this from
os.environ[<PVLIB TEST NREL API KEY>]
and use it instead of the DEMO key which has severe throttle limits and is shared by everyoneDescribe alternatives you've considered
just live with the test failures, or skip theses tests from the CI's
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: