Skip to content

MAINT: standardize spatial query parameter name to 'coordinates'#3609

Draft
keflavich wants to merge 4 commits into
astropy:mainfrom
keflavich:worktree-api-consolidation-2803
Draft

MAINT: standardize spatial query parameter name to 'coordinates'#3609
keflavich wants to merge 4 commits into
astropy:mainfrom
keflavich:worktree-api-consolidation-2803

Conversation

@keflavich

Copy link
Copy Markdown
Contributor

(this is an experiment @bsipocz - take with a heavy grain of salt, I tried out new claude fable this morning. My first-pass review says this is reasonable: it's actually pretty limited in scope, just changing coordinate->coordinates for the most part.)

Part of the API consolidation tracked in #2803: the first argument of the query_region/query_object/cone_search family is now uniformly named 'coordinates'. The old names ('coordinate' in alma, esa.euclid, esa.hsa, esa.jwst, gaia, ipac.irsa.ibe, noirlab; 'position' in esasky and heasarc; 'coord' in ogle) keep working via
deprecated_renamed_argument shims (since 0.4.12) and now emit AstropyDeprecationWarning.

In heasarc, the renamed parameter shadowed the 'from astropy import coordinates' module import, so that import was narrowed to the names actually used.

Part of the API consolidation tracked in astropy#2803: the first argument of
the query_region/query_object/cone_search family is now uniformly
named 'coordinates'. The old names ('coordinate' in alma, esa.euclid,
esa.hsa, esa.jwst, gaia, ipac.irsa.ibe, noirlab; 'position' in esasky
and heasarc; 'coord' in ogle) keep working via
deprecated_renamed_argument shims (since 0.4.12) and now emit
AstropyDeprecationWarning.

In heasarc, the renamed parameter shadowed the 'from astropy import
coordinates' module import, so that import was narrowed to the names
actually used.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.71689% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.62%. Comparing base (27510d1) to head (8c8b767).
⚠️ Report is 71 commits behind head on main.

Files with missing lines Patch % Lines
astroquery/esasky/core.py 82.35% 3 Missing ⚠️
astroquery/heasarc/core.py 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3609      +/-   ##
==========================================
+ Coverage   73.14%   73.62%   +0.47%     
==========================================
  Files         226      227       +1     
  Lines       21060    21212     +152     
==========================================
+ Hits        15405    15618     +213     
+ Misses       5655     5594      -61     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bsipocz

bsipocz commented Jun 10, 2026

Copy link
Copy Markdown
Member

Hmm, that is quite a few prominent modules, I would say if we do this it should have a very long deprecation period.

OTOH, we should also make sure if we change the parameter to plural then all these modules indeed work with a vector SkyCoord object.

Anyways; I'm milestoning it as "API clenaup" -- I would think that could be a release where we also break the versioning scheme and also do other API cleanups, so we break things only once.

@bsipocz bsipocz added this to the API cleanup milestone Jun 10, 2026
@keflavich

Copy link
Copy Markdown
Contributor Author

Good idea. I can mark it all deprecated and check whether they take vectors.

Should we formalize the API such that any services that don't take a vector use coordinate while those that take one or more use coordinates? I think that makes sense.

Audit of all renamed methods per review feedback: the parameter should
be plural 'coordinates' only where the method genuinely accepts
multiple positions, singular 'coordinate' otherwise.

Of the renamed modules, only ogle supports multiple positions (a list
of coordinates produces a valid multi-line query), so its rename to
'coordinates' stays. heasarc and esasky are single-position cone/box
searches, so their 'position' keyword is now deprecated in favor of
singular 'coordinate' instead. The seven modules that already used
'coordinate' for single-position queries (alma, esa.euclid, esa.hsa,
esa.jwst, gaia, ipac.irsa.ibe, noirlab) were named correctly all
along and are reverted to their original state.

All deprecations use deprecated_renamed_argument (since 0.4.12), so
the old keywords keep working with a warning.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bsipocz

bsipocz commented Jun 10, 2026

Copy link
Copy Markdown
Member

Should we formalize the API such that any services that don't take a vector use coordinate while those that take one or more use coordinates? I think that makes sense.

I think the astroquery API should always take the vectors and if there is no server side support we should just loop it in the module.

@keflavich

Copy link
Copy Markdown
Contributor Author

OK, I'm happy enough to do that. I think we've avoided it in some cases to avoid spamming the services. Should we impose a default (local) rate limit?

@bsipocz

bsipocz commented Jun 10, 2026

Copy link
Copy Markdown
Member

OK, I'm happy enough to do that. I think we've avoided it in some cases to avoid spamming the services. Should we impose a default (local) rate limit?

In those cases we could/should reach out and ask about their preferences. The spamming was prblematic when the service were supporting vector queries yet we did it in a loop of signletons

@keflavich

Copy link
Copy Markdown
Contributor Author

Yeah.... we can reach out, but for first pass, if we add a looped-singleton implementation where before there was none, I'd like to impose a default maximum number of parallel requests or a minimum time between requests. Are you ok with me doing that arbitrarily? It would be nice to clean up the API in a uniform sweep and handle archive detailed preferences later.

keflavich and others added 2 commits June 10, 2026 17:02
Resolution of the singular/plural question for the 'coordinates'
rename: instead of renaming scalar-only services back to singular,
give them real multi-coordinate support. The new
astroquery.utils.multicoord.support_multiple_coordinates decorator
lets a single-position query method accept a list of coordinates or a
non-scalar SkyCoord by running one query per position. Table results
are stacked with a query_index column mapping rows to inputs;
TableList results merge per key; anything else returns as a list in
input order.

Requests go through a bounded worker pool with a minimum spacing
between submissions. A survey of the affected archives (ESA/ESAC,
ALMA, IRSA, HEASARC, NOIRLab) found no published request-rate limits,
so the defaults are set conservatively (3 parallel requests, >=0.3 s
apart, i.e. ~3 requests/s aggregate) -- below every published limit
elsewhere (e.g. MAST's 5 req/s, SIMBAD's 6-10 q/s ban threshold) and
below the parallelism the archives' own tooling uses. Both knobs are
configurable via astroquery.utils.multicoord.conf.

Applied to gaia, esa.euclid, alma, esa.hsa, esa.jwst, esasky, heasarc,
ipac.irsa.ibe, and noirlab. ogle already supported lists natively.
For alma, an explicit sync query_region now exists (async_to_sync
skips it), which also fixes in-place mutation of a user-supplied
payload dict in repeated calls.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants