download_utilities

Attributes

_CONNECT_TIMEOUT

_READ_TIMEOUT

_RETRY_IF_FAILED

Functions

layup_downloader(→ pooch.HTTPDownloader)

A pooch HTTP downloader with a fail-fast timeout (issue #388).

make_retriever(→ pooch.Pooch)

Create a Pooch object to track and retrieve ephemeris files.

download_files_if_missing(→ None)

This function partially encapsulates the functionality of the

_check_for_existing_files(→ bool)

Will check for existing local files, any file not found will be printed

_decompress(→ None)

Override the functionality of Pooch's Decompress class so that the resulting

_remove_files(→ None)

Utility to remove all the files tracked by the pooch retriever. This includes

Module Contents

_CONNECT_TIMEOUT = 15[source]
_READ_TIMEOUT = 30[source]
_RETRY_IF_FAILED = 3[source]
layup_downloader(progressbar: bool = False) pooch.HTTPDownloader[source]

A pooch HTTP downloader with a fail-fast timeout (issue #388).

timeout is forwarded to requests.get as (connect, read). The read timeout is the maximum gap between received bytes, so it bounds a stalled connection without interrupting a slow-but-progressing large download (e.g. the ~600 MB JPL ephemeris keeps flowing, so it is never falsely cut off).

make_retriever(aux_config: layup.utilities.layup_configs.AuxiliaryConfigs, directory_path: str | None = None) pooch.Pooch[source]

Create a Pooch object to track and retrieve ephemeris files.

Parameters:
  • aux_config (AuxiliaryConfigs) – Dataclass of auxiliary configuration file arguments.

  • directory_path (string, optional) – The base directory to place all downloaded files. Default = None

Returns:

The instance of a Pooch object used to track and retrieve files.

Return type:

pooch.Pooch

download_files_if_missing(aux_config: layup.utilities.layup_configs.AuxiliaryConfigs, args: argparse.Namespace) None[source]

This function partially encapsulates the functionality of the layup.bootstrap command line tool. While layup.bootstrap allows for forced re-downloading of files, this function will only download files that are not already present in the local cache.

Parameters:
  • aux_configs (AuxiliaryConfigs) – Dataclass of configuration file arguments. This includes the AuxiliaryConfigs dataclass that contains the configuration for the bootstrap files.

  • args (Namespace) – The command line arguments. This includes the –cache argument that specifies the directory to store the downloaded files.

_check_for_existing_files(aux_config: layup.utilities.layup_configs.AuxiliaryConfigs, retriever: pooch.Pooch) bool[source]

Will check for existing local files, any file not found will be printed to the terminal.

Parameters:
  • aux_configs (AuxiliaryConfigs) – Dataclass of auxiliary configuration file arguments.

  • retriever (pooch.Pooch) – Pooch object that maintains the registry of files to download.

Returns:

Returns True if all files are found in the local cache, False otherwise.

Return type:

bool

_decompress(fname: str, action: str, pup: pooch.Pooch) None[source]

Override the functionality of Pooch’s Decompress class so that the resulting decompressed file uses the original file name without the compression extension. For instance filename.json.bz will be decompressed and saved as filename.json.

Parameters:
  • fname (str) – Original filename

  • action (str) – One of [“download”, “update”, “fetch”]

  • pup (pooch.Pooch) – The Pooch object that defines the location of the file.

Return type:

None

_remove_files(aux_config: layup.utilities.layup_configs.AuxiliaryConfigs, retriever: pooch.Pooch) None[source]

Utility to remove all the files tracked by the pooch retriever. This includes the decompressed ObservatoryCodes.json file as well as the META_KERNEL file that are created after downloading the files in the DATA_FILES_TO_DOWNLOAD list.

Parameters:
  • aux_config (AuxiliaryConfigs) – Dataclass of auxiliary configuration file arguments.

  • retriever (pooch.Pooch) – Pooch object that maintains the registry of files to download.

Return type:

None