Skip to content

Deprecate raw response from non-async method#3089

Merged
bsipocz merged 16 commits into
astropy:mainfrom
mkelley:mpc-deprecate-raw-response
Sep 6, 2024
Merged

Deprecate raw response from non-async method#3089
bsipocz merged 16 commits into
astropy:mainfrom
mkelley:mpc-deprecate-raw-response

Conversation

@mkelley

@mkelley mkelley commented Sep 2, 2024

Copy link
Copy Markdown
Contributor

Instead, direct users to use the async method.

  • A test was updated to use the async method for the raw response.
  • Cleaned up a few keyword parameters that actually didn't do anything, including some get_raw_response keywords.
  • Actually use the cache parameter in get_ephemerides.
  • Renamed a method to indicate that it is private (it isn't really useful outside of this module).
  • Updated remote tests. In particular, moved uncertainty column testing to use mocked data to avoid replacing yet another target that does not return uncertainty info anymore.

@mkelley mkelley added the mpc label Sep 2, 2024
@keflavich

Copy link
Copy Markdown
Contributor

Thanks! This change brings mpc more in line with the standard astroquery interface. 👍 from me.

@bsipocz bsipocz added this to the v0.4.8 milestone Sep 4, 2024

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some minor comments, mostly to do the deprecations properly (at least for one version cycle), and to clarify a bit around the test changes.

And while you're doing generic cleanup and maintenance, I wonder if you would mind having a look at the failing doctests in the narrative documentation, too. (pytest docs/mpc -R should do the trick of running them)

Comment thread astroquery/mpc/core.py
return self._request('GET', mpc_endpoint, params=request_args, auth=auth)

def get_mpc_object_endpoint(self, target_type):
def _get_mpc_object_endpoint(self, target_type):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is technically an API change (though wasn't used in the docs, nor has any docstrings in the API docs), so I would say, mentioning the cleanup the changelog would be sufficient.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread astroquery/mpc/core.py
perturbed=True, unc_links=False,
get_query_payload=False,
get_raw_response=False, cache=False):
get_query_payload=False, cache=False):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

changelog says deprecate, yet outright removed. Consider adding the decorator for now.

@mkelley mkelley Sep 5, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This one was removed rather than deprecated because the parameter was unused and had no effect on the method's behavior. I can deprecate it even though it doesn't do anything, or just add a comment in the change log.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The same comment for get_observatory_codes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mentioned these changes (and justification) in the change log.

Comment thread astroquery/mpc/core.py Outdated
return request_args

@class_or_instance
@deprecated_renamed_argument("get_raw_response", None, since="0.4.9",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is what needs to be done for the other methods, too.

Suggested change
@deprecated_renamed_argument("get_raw_response", None, since="0.4.9",
@deprecated_renamed_argument("get_raw_response", None, since="0.4.8",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment thread astroquery/mpc/core.py
alternative="async methods")
def get_observations_async(self, targetid, *,
id_type=None,
comettype=None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what happened with this parameter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was an unused parameter and doesn't correspond to anything in the API. I can make a comment in the change log.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mentioned in the change log.

result = mpc.core.MPC.get_ephemeris('2P', location='G37')
assert result['Moon phase'][0] >= 0

def test_get_ephemeris_Uncertainty(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What are the reason for removing these? I see that you mention to cleanup some tests to only run the mock versions but these seem to be removed for the mock test, too.

@mkelley mkelley Sep 5, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The uncertainty column is effectively tested with the test_get_ephemeris_unc_links method. Perhaps the method should be renamed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the remote file, and these are definitely the tests that need to be removed.

assert result['Moon phase'][0] >= 0


def test_get_ephemeris_Uncertainty(patch_post):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what are the reason for removing these tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, this is a mistake. I thought I had made a copy-paste error, but these were actually working mocked tests. I can restore them.

@mkelley mkelley Sep 6, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I partially thought it was a mistake because test_get_ephemeris_Moon_phase_and_Uncertainty was defined twice.

I think PR #3026 attempted to replace 1994 XG with 2024 AA, even though in the mocked tests it wasn't needed (because the mocked data didn't change, only the online results). I'll clean this up.

@mkelley

mkelley commented Sep 6, 2024

Copy link
Copy Markdown
Contributor Author

I've edited the doctest, too. It should now pass.

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @mkelley!

@bsipocz bsipocz merged commit e8fff0b into astropy:main Sep 6, 2024
@mkelley mkelley deleted the mpc-deprecate-raw-response branch September 6, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants