epicsarchiver.retrieval.client.async_archiver_retrieval ======================================================= .. py:module:: epicsarchiver.retrieval.client.async_archiver_retrieval .. autoapi-nested-parse:: Module for an asynchronous version of archiver retriever. Attributes ---------- .. autoapisummary:: epicsarchiver.retrieval.client.async_archiver_retrieval.LOG epicsarchiver.retrieval.client.async_archiver_retrieval.ENDPOINT_GET_DATA epicsarchiver.retrieval.client.async_archiver_retrieval.ENDPOINT_GET_MATCHING_PVS Classes ------- .. autoapisummary:: epicsarchiver.retrieval.client.async_archiver_retrieval.AsyncArchiverRetrieval Module Contents --------------- .. py:data:: LOG :type: logging.Logger .. py:data:: ENDPOINT_GET_DATA :value: '/data/getData.raw' .. py:data:: ENDPOINT_GET_MATCHING_PVS :value: '/bpl/getMatchingPVs' .. py:class:: AsyncArchiverRetrieval(hostname: str = 'localhost', port: int = DEFAULT_RETRIEVAL_PORT) Bases: :py:obj:`epicsarchiver.common.async_service.ServiceClient` Async retrieval client for the EPICS archiver appliance. Hold a session to the Archiver Appliance server to make retrieval requests. :param hostname: EPICS Archiver Appliance hostname :param port: EPICS Archiver Appliance retrieval port Examples: .. code-block:: python from epicsarchiver.archiver.retrieval import AsyncArchiverRetrieval async with AsyncArchiverRetrieval("archiver-01.tn.esss.lu.se") as archappl: events = await archappl.get_events( "my:pv", start=datetime.now(tz=UTC) - timedelta(seconds=1), end=datetime.utcnow(), ) .. py:attribute:: hostname :value: 'localhost' .. py:attribute:: port :value: 17668 .. py:attribute:: data_url :type: str :value: '' .. py:attribute:: matching_pvs_url :type: str :value: '' .. py:method:: __aenter__() -> Self :async: Asynchronous enter. Set url endpoints that will be used in this class: self.data_url: EPICS Archiver Appliance data retrieval URL. Use this url to retrieve pv data. self.matching_pvs_url: EPICS Archiver Appliance matching PVs URL. Use this url to search for pv names matching an input search string that can contain regex patterns. :returns: self :rtype: Self .. py:method:: get_data_raw(pv: str, start: datetime.datetime, end: datetime.datetime, fetch_latest_metadata: bool = True) -> aiohttp.ClientResponse :async: Fetch raw response from archiver data retrieval URL. :param pv: PV data requested for. :type pv: str :param start: Start time of period. :type start: datetime.datetime :param end: End time of period. :type end: datetime.datetime :param fetch_latest_metadata: Include latest EGU metadata in response. :type fetch_latest_metadata: bool :returns: Raw response from the archiver. :rtype: ClientResponse .. py:method:: _get_matching_pvs(query: str, limit: int) -> list[str] :async: Retrieve list of matching pv names for given regex search string. :param query: A regex search string. :type query: str :param limit: Limit of PV names to return. :type limit: int :returns: List of pv names :rtype: list[str] .. py:method:: _check_for_pvs_in_time_range(query: list[str], start: datetime.datetime | None = None, end: datetime.datetime | None = None) -> list[str] :async: Check if data recorded during the given time range for each PV in list. If both start and end given, return only PVs which recorded data during that time range. If start given and end not, return PVs which recorded data between start and now. If end given and start not, return PVs which recorded any data before end. :param query: List of pvs. :type query: list[str] :param start: Start of the time range. :type start: datetime.datetime | None :param end: End of the time range. :type end: datetime.datetime | None :returns: List of PV names found. :rtype: list[str] .. py:method:: get_events(pv: str, start: datetime.datetime, end: datetime.datetime, processor: epicsarchiver.retrieval.client.processor.Processor | None = None) -> list[epicsarchiver.retrieval.archive_event.ArchiveEvent] :async: Get a list of events from the archiver for specified pv and time period. :param pv: PV data requested for. :type pv: str :param start: Start time of the time period. :type start: datetime.datetime :param end: End time of the time period. :type end: datetime.datetime :param processor: Optional Preprocessor to use. Defaults to None. :type processor: Processor | None, optional :returns: List of events in time period. :rtype: list[ArchiveEvent] .. py:method:: get_archive_data(pv: str, start: datetime.datetime, end: datetime.datetime, processor: epicsarchiver.retrieval.client.processor.Processor | None = None) -> epicsarchiver.retrieval.archive_event.ArchiveEventsData :async: Get events from the archiver for specified pv and time period with metadata. :param pv: PV data requested for. :type pv: str :param start: Start time of the time period. :type start: datetime.datetime :param end: End time of the time period. :type end: datetime.datetime :param processor: Optional Preprocessor to use. Defaults to None. :type processor: Processor | None, optional :returns: Metadata per year, list of events in time period. :rtype: ArchiveEventsData .. py:method:: get_all_events(pvs: set[str], start: datetime.datetime, end: datetime.datetime, processor: epicsarchiver.retrieval.client.processor.Processor | None = None) -> dict[str, list[epicsarchiver.retrieval.archive_event.ArchiveEvent]] :async: Get a list of events for every pv requested. Makes all the calls to the archiver asynchronously, so some maybe made in parallel. :param pvs: Set of pvs data wanted for. :type pvs: set[str] :param start: Start time of period. :type start: datetime.datetime :param end: End time of period. :type end: datetime.datetime :param processor: Optional choice of Preprocessor. Defaults to None. :type processor: Processor | None, optional :returns: Dictionary of pvs (keys) and events (values). :rtype: dict[str, list[ArchiveEvent]] .. py:method:: search(query: str, *, start: datetime.datetime | None = None, end: datetime.datetime | None = None, limit: int = 500) -> list[str] :async: Search for names of PVs matching the given regex search string. Optionally specify start and/or end times to only return PVs that recorded data in the specified time range. :param query: A regex search string. :type query: str :param start: Start time of the time period. :type start: datetime.datetime | None :param end: End time of the time period. :type end: datetime.datetime | None :param limit: Limit of PV names to return for each search string given. To get all the PV names, (potentially in the millions), set limit to -1. [default: 500] :type limit: int :returns: List of PV names found. :rtype: list[str]