Skip to content

GAIA: update the method load_data to return the path of the downloaded DataLink archive - #3673

Merged
bsipocz merged 4 commits into
astropy:mainfrom
esdc-esac-esa-int:ESAC_Gaia_GAIASA-3522_method_Gaia-load_data_returns_tuple
Nov 4, 2026
Merged

bsipocz merged 4 commits into
astropy:mainfrom
esdc-esac-esa-int:ESAC_Gaia_GAIASA-3522_method_Gaia-load_data_returns_tuple

Conversation

@cosmoJFH

@cosmoJFH cosmoJFH commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Dear Astroquery team,

we have opened this PR since we'd like to update the Gaia.load_data method to return the path of the downloaded DataLink archive when dump_to_file=True.

Currently, load_data prints the generated archive path but does not make it available programmatically. Returning the path allows users to directly access and process downloaded products, which is particularly useful for the upcoming Gaia DR4 residual_image products.

We have implemented the following changes:

  1. Return None when dump_to_file=False.
  2. Return the absolute path to the downloaded ZIP file when dump_to_file=True.
  3. Preserve the existing method signature and backwards compatibility.

Example

dl_dict, out_path = Gaia.load_data(
    ids=ids,
    data_release="Gaia DR4_RC3",
    retrieval_type="RESIDUAL_IMAGE",
    data_structure="DATAMODEL_STANDARD",
    dump_to_file=True,
    format="fits",
)

cc @esdc-esac-esa-int
jira: GAIASA-3522

@keflavich

Copy link
Copy Markdown
Contributor

The proposed API seems fine to me.

This should be accompanied by a warning, since it will change the output of load_data from a single table entry to (table, string), right?

An alternative approach is to leave the default behavior as-is (table = Gaia.load_data(dump_to_file=False)) and only add the new return if the file is dumped (table, path = Gaia.load_data(dump_to_File=True)).

I may slightly prefer the latter but I don't feel strongly. I'll check what we do elsewhere in astroquery...

@cosmoJFH
cosmoJFH force-pushed the ESAC_Gaia_GAIASA-3522_method_Gaia-load_data_returns_tuple branch from 84e1f46 to ff2fa5a Compare October 1, 2026 16:35
@cosmoJFH

cosmoJFH commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

The proposed API seems fine to me.

This should be accompanied by a warning, since it will change the output of load_data from a single table entry to (table, string), right?

An alternative approach is to leave the default behavior as-is (table = Gaia.load_data(dump_to_file=False)) and only add the new return if the file is dumped (table, path = Gaia.load_data(dump_to_File=True)).

I may slightly prefer the latter but I don't feel strongly. I'll check what we do elsewhere in astroquery...

Hi @keflavich, thanks for your feedback. I will discuss this alternative implementation with the rest of the team.

@cosmoJFH
cosmoJFH force-pushed the ESAC_Gaia_GAIASA-3522_method_Gaia-load_data_returns_tuple branch from a5983b0 to 2090536 Compare October 1, 2026 17:22
@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.05%. Comparing base (c41a46a) to head (274d877).
⚠️ Report is 36 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3673      +/-   ##
==========================================
+ Coverage   73.86%   74.05%   +0.19%     
==========================================
  Files         228      228              
  Lines       21475    21649     +174     
==========================================
+ Hits        15863    16033     +170     
- Misses       5612     5616       +4     

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

@cosmoJFH
cosmoJFH force-pushed the ESAC_Gaia_GAIASA-3522_method_Gaia-load_data_returns_tuple branch 5 times, most recently from fb3e3c6 to d449dcb Compare October 1, 2026 18:54
@bsipocz bsipocz added the gaia label Oct 2, 2026
@cosmoJFH cosmoJFH changed the title GAIA: update the method gaia load data returns the path of the downloaded DataLink archive GAIA: update the method load_data to return the path of the downloaded DataLink archive Oct 3, 2026
@cosmoJFH
cosmoJFH force-pushed the ESAC_Gaia_GAIASA-3522_method_Gaia-load_data_returns_tuple branch 2 times, most recently from ae385b4 to 3cfc2e0 Compare October 3, 2026 08:30
@cosmoJFH

cosmoJFH commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

We’d prioritize backward compatibility, so we’ve updated the implementation as follows:

  • dump_to_File=False → dict[str, Table] (original behavior)
  • dump_to_File=True → tuple[dict[str, Table], str]

We think this is the least disruptive migration, although it does make the type annotation a little more complicated.

We haven’t added a warning because there’s no deprecated behaviour for existing users.

@keflavich

Copy link
Copy Markdown
Contributor

I'm happy with that change.

I would still want some kind of warning about the API change, but this can just go in the changelog, not necessarily the code - the return type may now be a tuple instead of a dict.

@bsipocz what do you think?

@cosmoJFH
cosmoJFH force-pushed the ESAC_Gaia_GAIASA-3522_method_Gaia-load_data_returns_tuple branch 2 times, most recently from a6fc4ec to 2a1e2be Compare October 4, 2026 17:23
@cosmoJFH
cosmoJFH force-pushed the ESAC_Gaia_GAIASA-3522_method_Gaia-load_data_returns_tuple branch 2 times, most recently from 1947910 to 5704eb3 Compare October 19, 2026 18:10

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

The API looks reasonable, my only comment is about if we really need that type annotation.

Comment thread astroquery/gaia/core.py
Comment on lines +168 to +188
@overload
def load_data(self, ids, *, data_release=None, data_structure='DATAMODEL_STANDARD', retrieval_type="ALL",
linking_parameter='SOURCE_ID', valid_data=False, band=None, avoid_datatype_check=False,
format="votable", dump_to_file: Literal[False] = False, overwrite_output_file=False, verbose=False,
output_file=None) -> dict[str, Table]:
...

@overload
def load_data(self, ids, *, data_release=None, data_structure='DATAMODEL_STANDARD', retrieval_type="ALL",
linking_parameter='SOURCE_ID', valid_data=False, band=None, avoid_datatype_check=False,
format="votable", dump_to_file: Literal[True], overwrite_output_file=False, verbose=False,
output_file=None) -> tuple[dict[str, Table], str]:
...

@overload
def load_data(self, ids, *, data_release=None, data_structure='DATAMODEL_STANDARD', retrieval_type="ALL",
linking_parameter='SOURCE_ID', valid_data=False, band=None, avoid_datatype_check=False,
format="votable", dump_to_file: bool, overwrite_output_file=False, verbose=False,
output_file=None) -> dict[str, Table] | tuple[dict[str, Table], str]:
...

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.

I'm not at all a fan of this, or in fact any typing -- we don't enforce it and we are never dispatching into a computationally performant algorithm either.
Is there a particular reason you want this?

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'm not at all a fan of this, or in fact any typing -- we don't enforce it and we are never dispatching into a computationally performant algorithm either. Is there a particular reason you want this?

Hi @bsipocz, we just thought it would be a useful way to distinguish between the three possible scenarios while maintaining backward compatibility. What would you suggest?

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.

ahh, ok, I see what you mean. I suppose it's OK then for this one case, but overall I would still say that we may not want to overcomplicate our life by doing types when this is not code where we ever really need.

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.

Hi @bsipocz, we’d be happy to implement whichever solution you think is best. The current implementation is one possible approach, but we’re open to your suggestions and would be happy to follow your recommendation.

@cosmoJFH
cosmoJFH force-pushed the ESAC_Gaia_GAIASA-3522_method_Gaia-load_data_returns_tuple branch 2 times, most recently from ed1de06 to 3cd0b9c Compare October 26, 2026 20:40
@cosmoJFH
cosmoJFH force-pushed the ESAC_Gaia_GAIASA-3522_method_Gaia-load_data_returns_tuple branch from 3cd0b9c to 9b9f411 Compare November 2, 2026 13:03
@bsipocz bsipocz added this to the 0.4.12 milestone Nov 3, 2026

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

The RTD failure is genuine, and to fix it I added commit here that turns off typehints for the documentation.

That being said, we'll keep seeing RTD failures, but those are unrelated and are due to the currently unavailable requests intersphinx mapping.

@bsipocz
bsipocz merged commit 46feb44 into astropy:main Nov 4, 2026
9 of 10 checks passed
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