uvex_transients.utils.results.get_results#
- uvex_transients.utils.results.get_results(assets: list[str] | None = None, tag: str | None = None, directory: str | PathLike | None = None, overwrite: bool = False, timeout: float = 60.0, simulation: str | None = None) dict[str, Path][source]#
Download assets of a published release and return their local paths.
Files already present with the expected size are not downloaded again, so repeated calls only cost one small request to the GitHub API, to learn which release is newest. By default the files are kept in the package cache directory, in a subdirectory per release (
<cache_dir>/results/<tag>/), so different releases never mix.- Parameters:
assets (
listofstr, optional) – What to fetch, each either a key of RESULT_ASSETS ("events","exposure","photometry","summary") or a file name. The default is every file of the release (or of the simulation), including the large photometry table, so asking for only what you need is usually better.tag (
str, optional) – The release tag to fetch. The default is the newest published release.directory (
stroros.PathLike, optional) – Place the files directly in this directory instead of the per-release cache directory.overwrite (
bool, optional) – Replace an existing file whose size differs from the release asset. The default raises instead, so an explicit directory holding results from another release is never silently overwritten.timeout (
float, optional) – Network timeout in seconds, per request. The default is 60.simulation (
str, optional) – Fetch from a secondary simulation (see list_simulations, for example"infant_sne") instead of the release’s primary run. Each is attached as<simulation>.zipholding the same files as the primary run, under the same RESULT_ASSETS keys. Only the requested files are downloaded from the archive, using HTTP range requests. Files are cached in<cache_dir>/results/<tag>/<simulation>/. The default is the primary run.
- Returns:
Each requested name, as given in assets, mapped to its local path.
- Return type:
dictofstrtopathlib.Path- Raises:
ConnectionError – If the GitHub releases API cannot be reached.
LookupError – If there are no published releases, tag does not exist, simulation is not on the release, or a requested asset is not on the release (or in the simulation).
FileExistsError – If a file already exists with a different size than the release asset and overwrite is False.
Examples
from uvex_transients.simulation import ( EventCatalog, ) from uvex_transients.utils import get_results paths = get_results(["events", "summary"]) events = EventCatalog.from_disk(paths["events"]) # The same files from a secondary simulation. infant = get_results( ["summary"], simulation="infant_sne" )