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

Avoid assuming that access_url exists always #570

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aragilar
Copy link
Contributor

@aragilar aragilar commented Jul 1, 2024

DatalinkResultsMixin was assuming that the records created by any subclass would have the access_url attribute. This is not true for SSA (whether it should do is a separate question). This replaces that assumption with a check for existence first, and then if that fails, fall back to getdatalink on the record.

See #569 for more context.

I'm not sure this is the right solution (especially around the fallback, as that's what the previous code did before the batching in #218), but it does work, both in that I no longer get an exception, and I can iterate over the datalink urls in the SSA results.

Fixes: #569

DatalinkResultsMixin was assuming that the records created by any
subclass would have the `access_url` attribute. This is not true for SSA
(whether it should do is a separate question). This replaces that
assumption with a check for existence first, and then if that fails,
fall back to getdatalink on the record.
Copy link
Contributor

@msdemlei msdemlei left a comment

Choose a reason for hiding this comment

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

Until we have a more general solution for #543, I'd say this is a reasonable stop-gap measure.

The failing tests seem to be remote failures. I'd say this can live without a changelog entry, as the behaviour we are changing is neither sane nor expectable, nor will anyone rely on it.

I'll still look at #543 unless someone beats me to it (which I would like a lot!)

@aragilar
Copy link
Contributor Author

aragilar commented Jul 1, 2024

Oh, I missed #543, as I was looking for SSA-related issues. As I noted, I'm not clear on which classes/mixins are supposed to be responsible for which parts, and what subclasses are expected to implement.

@bsipocz bsipocz added this to the v1.5.3 milestone Jul 1, 2024
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.

Could you maybe add a test for the SSA case that used to fail and now passes?

@aragilar
Copy link
Contributor Author

aragilar commented Jul 5, 2024

Sure, should I dump an example VOTable in the data dir and try to load it? Do we have a expected way to mock out requests (as at least in my case, the service in still at the beta url, and so the urls aren't stable yet)?

@msdemlei
Copy link
Contributor

msdemlei commented Jul 5, 2024 via email

@bsipocz
Copy link
Member

bsipocz commented Jul 9, 2024

There are some minimal test mocking guidelines at astroquery, it would be nice to make one that works for both packages: https://astroquery.readthedocs.io/en/latest/testing.html

But overall, I agree with Markus' suggestion, your best bet is to look for existing tests that do similar mocking and copy those as we don't really have good enough docs for this.

@msdemlei
Copy link
Contributor

@aragilar -- if you don't find time to fiddle a test let me know and I'll have a pass at it (I know these are a pain; I have tried to make making tests simpler and failed before).

@bsipocz
Copy link
Member

bsipocz commented Aug 12, 2024

ping @aragilar about this, do you have an ETA for coming back to this PR?

@aragilar
Copy link
Contributor Author

Sorry, been on leave for the past month, I'll try to get back into this soon (but if people want to jump in and modify things, feel free to do so).

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.

'SSARecord' object has no attribute 'access_format'
3 participants