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

Remove default wavelength limits from svo_fps get_filter_index() #2509

Merged
merged 5 commits into from
Sep 7, 2022

Conversation

eerovaher
Copy link
Member

So far the default behaviour of get_filter_index() from svo_fps has been to make the wavelength range as large as possible, but that results in a timeout. Now the method requires the user to explicitly set the wavelength limits. Although this is backwards incompatible, in practice the user already had to provide the limits and if they don't then it is better to receive an immediate TypeError about missing mandatory arguments than it is to wait a minute before an obscure timeout occurs.

See also 90677c8

Closes #2508

Previously the default behaviour of `get_filter_index()` from `svo_fps`
was to make the wavelength range as large as possible, but that results
in a timeout. Now the method requires the user to explicitly set the
wavelength limits because it is better to receive an immediate
`TypeError` about missing mandatory arguments than it is to wait a
minute before an obscure timeout occurs.

See also 90677c8
@keflavich
Copy link
Contributor

This is only a partial solution, I think - I just got a timeout for a rather reasonable query:

from astroquery.svo_fps import SvoFps
index = SvoFps.get_filter_index(1000*u.AA, 1*u.um)

It may be that we just need to increase the timeout, since there are apparently now too many optical filters?

@codecov
Copy link

codecov bot commented Sep 6, 2022

Codecov Report

Merging #2509 (8dd1954) into main (85b3937) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 8dd1954 differs from pull request most recent head 74ff202. Consider uploading reports for the commit 74ff202 to get more accurate results

@@            Coverage Diff             @@
##             main    #2509      +/-   ##
==========================================
- Coverage   62.99%   62.98%   -0.01%     
==========================================
  Files         133      133              
  Lines       17293    17310      +17     
==========================================
+ Hits        10893    10902       +9     
- Misses       6400     6408       +8     
Impacted Files Coverage Δ
astroquery/svo_fps/core.py 95.45% <100.00%> (+0.21%) ⬆️
astroquery/alma/core.py 47.83% <0.00%> (-0.37%) ⬇️
astroquery/exceptions.py 0.00% <0.00%> (ø)
astroquery/mast/observations.py 76.66% <0.00%> (+0.04%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@eerovaher
Copy link
Member Author

A larger timeout limit makes it simpler to (accidentally) download very large files, so I'm not sure it would be a good idea to change the default. I would rather make the error message more helpful.

@keflavich
Copy link
Contributor

One thing we can add to this is to query only astronomical, earth observing, or planetary missions. I believe that is through the asttype keyword, though I haven't verified yet.

@keflavich
Copy link
Contributor

Right, I agree - the problem seems to be that the error is simply a timeout, and there's not really a great reason for it. Even getting all the filters' metadata is only a few MB, but apparently the server has a hard time retrieving everything.

@keflavich
Copy link
Contributor

Unfortunately, the asttype parameter, which is available in the webform-based query, is not listed on the VO keyword page:
http://svo2.cab.inta-csic.es/theory/fps/index.php?mode=voservice

@bsipocz bsipocz added this to the v0.4.7 milestone Sep 6, 2022
@bsipocz
Copy link
Member

bsipocz commented Sep 6, 2022

Suggested changes look good to me, but maybe make a note about the timeout issue in the docs?

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

Adding one more note and example about acknowledging the timeout issue, to the docs would be great to be part of this fix. The rest of my comments are optional.

I recognize that the docs was skipped running prior this PR, so cleaning the doctest-skip all, as well as cleaning up the usage of **kwargs are optional extensions of the PR.

@@ -80,19 +78,17 @@ def data_from_svo(self, query, cache=True, timeout=None,
# If no table element found in VOTable
raise IndexError(error_msg)

def get_filter_index(self, wavelength_eff_min=0*u.angstrom,
wavelength_eff_max=FLOAT_MAX*u.angstrom, **kwargs):
def get_filter_index(self, wavelength_eff_min, wavelength_eff_max, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

if you're interested in more cleanup here, there is no reason for using kwargs here, list them out instead, here and for the other methods, too.

Copy link
Member Author

Choose a reason for hiding this comment

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

To be honest I am not interested in cleaning up svo_fps in the foreseeable future.

There are options to downselect based on the minimum
and maximum effective wavelength (``wavelength_eff_min``
and ``wavelength_eff_max``, respectively).
.. doctest-skip-all
Copy link
Member

Choose a reason for hiding this comment

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

why skipping the rest? Instead skipping please refactor so that doctests are passed.

Maybe also add another example with a note that timeout issues are expected, but can be fixed with the passing a large timeout as kwarg.

Copy link
Member Author

Choose a reason for hiding this comment

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

Would you prefer turning on testing for all the code examples to be done in a commit in this pull request or would a separate pull request be more appropriate?

Copy link
Member

Choose a reason for hiding this comment

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

Having it here would be fine, after all this is a very short and non-complicated docs.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have turned on remote testing for more code blocks and ensured that the example output matches actual output. The plotting example is still being skipped, but it doesn't execute any astroquery code, so I'll leave it the way it is.

Copy link
Member

Choose a reason for hiding this comment

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

all plotting examples should be using the .. plot:: directive at some point, or should be removed, but that's a scope outside of this PR.

If `get_filter_index()` fails because the server took too long to
resolve the query then the resulting `TimeoutError` suggests making the
wavelength range smaller, or increasing the timeout limit if a large
range is needed. The documentation now also makes the same suggestions.
@eerovaher
Copy link
Member Author

There are now suggestions about avoiding timeouts in both the error message that occurs if the server takes too long to respond, and in the narrative docs.

Now the only code block in `svo_fps` docs that is not being tested at
all is a plotting example, but it doesn't execute any `astroquery` code.
docs/svo_fps/svo_fps.rst Outdated Show resolved Hide resolved
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

One minor thing that I committed directly.

@bsipocz
Copy link
Member

bsipocz commented Sep 7, 2022

Thanks @eerovaher!

@bsipocz bsipocz merged commit 3385abf into astropy:main Sep 7, 2022
@eerovaher eerovaher deleted the svo-fps-wavelengths branch September 7, 2022 23:42
ceb8 pushed a commit to orionlee/astroquery that referenced this pull request Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot connect to SVO Filter Profile Service
3 participants