find_latest¶
- gwdatafind.find_latest(
- site,
- frametype,
- urltype='file',
- on_missing='error',
- host=None,
- api='v1',
- ext='gwf',
- session=None,
- **request_kw,
Query a GWDataFind host for the latest file in a given dataset.
- Parameters:
site (
str) – single-character name of site to matchframetype (
str) – name of dataset to matchurltype (
str, optional) – URL scheme to search foron_missing (
str, optional) –what to do when the requested file isn’t found, one of:
'error': raise aRuntimeError'warn': print a warning but return an emptylist'ignore': return an emptylistwith no warnings
host (
str, optional) – the URL/name of the GWDataFind host to query; if not givenget_default_host()will be used to discover the default host.api (
str, optional) – The API version to use. Defaults to the value of theGWDATAFIND_APIenvironment variable, or"v1"if not set.ext (
str, optional) – the file extension for which to search.session (
requests.Session, optional) – the connection session to use; if not given, aigwn_auth_utils.Sessionwill be created on-the-flytoken – passed directly to
igwn_auth_utils.Session, see SciTokens for more details.token_audience – passed directly to
igwn_auth_utils.Session, see SciTokens for more details.token_scope – passed directly to
igwn_auth_utils.Session, see SciTokens for more details.cert – passed directly to
igwn_auth_utils.Session, see X.509 for more details.request_kw – other keywords are passed to
igwn_auth_utils.get()
- Returns:
urls (
listofstr) – a list of URLs for the latest file found- Raises:
requests.RequestException – if the request fails for any reason
RuntimeError – if no latest file is found and
on_missing="error"was given
Examples
>>> find_latest('H', 'H1_GWOSC_O2_4KHZ_R1', urltype='file', host='datafind.gwosc.org')) ['file://localhost/cvmfs/gwosc.osgstorage.org/gwdata/O2/strain.4k/frame.v1/H1/1186988032/H-H1_GWOSC_O2_4KHZ_R1-1187733504-4096.gwf']