wags_tails.custom#
Provide data acquisition class for custom data acquisition needs.
Some source data (e.g. Wikidata, for Thera-py), fetching data is a more involved and
customized process, but this library should be very dependency-light to ensure broad
compatibility. The CustomData abstract class is provided so that users can employ
basic wags-tails utilities without also burdening it with their own software
dependencies.
The documentation provides more explanation and an in-depth example.
- class wags_tails.custom.CustomData(src_name, filetype, latest_version_cb, download_cb, data_dir=None, file_name=None, versioned=True, silent=False)[source]#
Data acquisition class using custom, user-provided acquisition methods.
- __init__(src_name, filetype, latest_version_cb, download_cb, data_dir=None, file_name=None, versioned=True, silent=False)[source]#
Set common class parameters.
- Parameters:
src_name (
str) – Name of source. Used to set some default file naming and location parameters.filetype (
str) – file type suffix, e.g."tsv". Used to set some default naming and location parameters.latest_version_cb (
Callable[[],str]) – function for acquiring latest version, returning that value as a stringdownload_cb (
Callable[[str,Path],None]) – function for acquiring data, taking arguments for the Path to save the file to, and the latest version of the datadata_dir (
Optional[Path]) – direct location to store data files in, if specified. Seeget_data_dir()in thestorage_utilsmodule for further configuration details.file_name (
Optional[str]) – name to use for base of filename if givensilent (
bool) – if True, don’t print any info/updates to console
- _get_latest_version()[source]#
Acquire value of latest data version.
This method is overwritten by the
latest_version_cbargument supplied at class initialization. It is defined here as an empty method to suppress abstract base class checks.- Return type:
str- Returns:
latest version value
- _download_data(version, outfile)[source]#
Download data file to specified location.
This method is overwritten by the
download_cbargument supplied at class initialization. It is defined here as an empty method to suppress abstract base class checks.- Parameters:
version (
str) – version to acquireoutfile (
Path) – location and filename for final data file
- Return type:
None