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

Deprecate raw response from non-async method #3089

Merged
merged 16 commits into from
Sep 6, 2024

Conversation

mkelley
Copy link
Contributor

@mkelley mkelley commented Sep 2, 2024

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
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
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.

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)

@@ -329,7 +330,7 @@ def query_objects_async(self, target_type, *, get_query_payload=False, **kwargs)
auth = (self.MPC_USERNAME, self.MPC_PASSWORD)
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
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
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -344,8 +345,7 @@ def get_ephemeris_async(self, target, *, location='500', start=None, step='1d',
proper_motion='total', proper_motion_unit='arcsec/h',
suppress_daytime=False, suppress_set=False,
perturbed=True, unc_links=False,
get_query_payload=False,
get_raw_response=False, cache=False):
get_query_payload=False, cache=False):
Copy link
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.

Copy link
Contributor Author

@mkelley mkelley Sep 5, 2024

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
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
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.

@@ -771,9 +764,10 @@ def _args_to_ephemeris_payload(self, **kwargs):
return request_args

@class_or_instance
@deprecated_renamed_argument("get_raw_response", None, since="0.4.9",
Copy link
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
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

def get_observations_async(self, targetid, *,
id_type=None,
comettype=None,
Copy link
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
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
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.

@@ -82,17 +81,6 @@ def test_get_ephemeris_Moon_phase(self):
result = mpc.core.MPC.get_ephemeris('2P', location='G37')
assert result['Moon phase'][0] >= 0

def test_get_ephemeris_Uncertainty(self):
Copy link
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.

Copy link
Contributor Author

@mkelley mkelley Sep 5, 2024

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
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.

@@ -176,19 +176,6 @@ def test_get_ephemeris_Moon_phase(patch_post):
assert result['Moon phase'][0] >= 0


def test_get_ephemeris_Uncertainty(patch_post):
Copy link
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
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.

Copy link
Contributor Author

@mkelley mkelley Sep 6, 2024

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
Copy link
Contributor Author

mkelley commented Sep 6, 2024

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

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.

Thanks @mkelley!

@bsipocz bsipocz merged commit e8fff0b into astropy:main Sep 6, 2024
9 checks passed
@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