siibra.retrieval.requests
Request files with decoders, lazy loading, and caching.
Attributes
Exceptions
Common base class for all non-exit exceptions. |
|
Common base class for all non-exit exceptions. |
Classes
Implements lazy loading of HTTP Knowledge graph queries. |
|
Just a loads a local file, but mimics the behaviour |
|
Generic enumeration. |
|
Functions
|
By supplying a url or a filename, obtain a suitable decoder function |
|
Helper method to provide BytesIO to methods that only takes file path and |
Module Contents
- exception siibra.retrieval.requests.MultiSourceRequestException
Common base class for all non-exit exceptions.
- exception siibra.retrieval.requests.SiibraHttpRequestError(url: str, status_code: int, msg='Cannot execute http request.')
Common base class for all non-exit exceptions.
- __str__()
Return str(self).
- msg = 'Cannot execute http request.'
- status_code
- url
- class siibra.retrieval.requests.EbrainsRequest(url, decoder=None, params={}, msg_if_not_cached=None, post=False)
Implements lazy loading of HTTP Knowledge graph queries.
- classmethod device_flow(**kwargs)
- classmethod fetch_token(**kwargs)
Fetch an EBRAINS token using commandline-supplied username/password using the data proxy endpoint.
Details on how to access EBRAINS are here.
- get()
Evaluate KG Token is evaluated only on execution of the request.
- classmethod init_oidc()
- classmethod set_token(token)
- property auth_headers
- keycloak_endpoint = 'https://iam.ebrains.eu/auth/realms/hbp/protocol/openid-connect/token'
- property kg_token
- params
- class siibra.retrieval.requests.FileLoader(filepath, func=None)
Just a loads a local file, but mimics the behaviour of cached http requests used in other connectors.
- cachefile
- class siibra.retrieval.requests.GitlabProxy(flavour: GitlabProxyEnum, instance_id=None)
- flavour
- folder
- folder_dict
- get
- instance_id = None
- class siibra.retrieval.requests.GitlabProxyEnum
Generic enumeration.
Derive from this class to define new enumerations.
- get(filename, decode_func=None, *, connector: siibra.retrieval.repositories.GitlabConnector = None)
- search_files(folder: str, suffix=None, recursive=True, *, connector: siibra.retrieval.repositories.GitlabConnector = None) List[str]
- DATASETVERSION_V3 = 'DATASETVERSION_V3'
- DATASET_V1 = 'DATASET_V1'
- DATASET_V3 = 'DATASET_V3'
- PARCELLATIONREGION_V1 = 'PARCELLATIONREGION_V1'
- property connectors: List[siibra.retrieval.repositories.GitlabConnector]
- class siibra.retrieval.requests.HttpRequest(url: str, func: Callable = None, msg_if_not_cached: str = None, refresh=False, post=False, **kwargs)
- get()
- property cached
- cachefile
- property data
- kwargs
- msg_if_not_cached = None
- post = False
- refresh = False
- url
- class siibra.retrieval.requests.MultiSourcedRequest(requests: List[HttpRequest])
- get()
- property data
- requests: List[HttpRequest] = []
- class siibra.retrieval.requests.ZipfileRequest(url, filename, func=None, refresh=False)
- get()
- filename
- siibra.retrieval.requests.find_suitiable_decoder(url: str) Callable
By supplying a url or a filename, obtain a suitable decoder function for siibra to digest based on predefined DECODERS. An extra layer of gzip decompressor automatically added for gzipped files.
- Parameters:
url (str) – The url or filename with extension.
- Return type:
Callable or None
- siibra.retrieval.requests.read_as_bytesio(function: Callable, suffix: str, bytesio: io.BytesIO)
Helper method to provide BytesIO to methods that only takes file path and cannot handle BytesIO normally (e.g., nibabel.freesurfer.read_annot()).
Writes the bytes to a temporary file on cache and reads with the original function.
- Parameters:
function (Callable) –
suffix (str) – Must match the suffix expected by the function provided.
bytesio (BytesIO) –
- Return type:
Return type of the provided function.
- siibra.retrieval.requests.try_all_connectors()
- siibra.retrieval.requests.DECODERS
- siibra.retrieval.requests.USER_AGENT_HEADER