epicsarchiver.retrieval.archiver_retrieval.async_archiver_retrieval

Module for an asynchronous version of archiver retriever.

Attributes

LOG

ENDPOINT_GET_DATA

ENDPOINT_GET_MATCHING_PVS

Classes

AsyncArchiverRetrieval

Async retrieval client for the EPICS archiver appliance.

Module Contents

epicsarchiver.retrieval.archiver_retrieval.async_archiver_retrieval.LOG: logging.Logger[source]
epicsarchiver.retrieval.archiver_retrieval.async_archiver_retrieval.ENDPOINT_GET_DATA = '/data/getData.raw'[source]
epicsarchiver.retrieval.archiver_retrieval.async_archiver_retrieval.ENDPOINT_GET_MATCHING_PVS = '/bpl/getMatchingPVs'[source]
class epicsarchiver.retrieval.archiver_retrieval.async_archiver_retrieval.AsyncArchiverRetrieval(hostname: str = 'localhost', port: int = 17665)[source]

Bases: 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.

Parameters:
  • hostname – EPICS Archiver Appliance hostname [default: localhost]

  • port – EPICS Archiver Appliance management port [default: 17665]

Examples:

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(),
    )
hostname = 'localhost'[source]
port = 17665[source]
_data_retrieval_url: str = ''[source]
data_url: str = ''[source]
matching_pvs_url: str = ''[source]
async __aenter__() Self[source]

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

Return type:

Self

async _get_data_raw(pv: str, start: datetime.datetime, end: datetime.datetime) aiohttp.ClientResponse[source]

Fetch raw response from archiver data retrieval URL.

Parameters:
Returns:

Raw response from the archiver.

Return type:

ClientResponse

async _get_matching_pvs(query: str, limit: int) list[str][source]

Retrieve list of matching pv names for given regex search string.

Parameters:
  • query (str) – A regex search string.

  • limit (int) – Limit of PV names to return.

Returns:

List of pv names

Return type:

list[str]

async _check_for_pvs_in_time_range(query: list[str], start: datetime.datetime | None = None, end: datetime.datetime | None = None) list[str][source]

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.

Parameters:
Returns:

List of PV names found.

Return type:

list[str]

async get_events(pv: str, start: datetime.datetime, end: datetime.datetime, processor: epicsarchiver.retrieval.archiver_retrieval.processor.Processor | None = None) list[epicsarchiver.retrieval.archive_event.ArchiveEvent][source]

Get a list of events from the archiver for specified pv and time period.

Parameters:
  • pv (str) – PV data requested for.

  • start (datetime.datetime) – Start time of the time period.

  • end (datetime.datetime) – End time of the time period.

  • processor (Processor | None, optional) – Optional Preprocessor to use. Defaults to None.

Returns:

List of events in time period.

Return type:

list[ArchiveEvent]

async get_archive_data(pv: str, start: datetime.datetime, end: datetime.datetime, processor: epicsarchiver.retrieval.archiver_retrieval.processor.Processor | None = None) epicsarchiver.retrieval.pb.ArchiveEventsData[source]

Get events from the archiver for specified pv and time period with metadata.

Parameters:
  • pv (str) – PV data requested for.

  • start (datetime.datetime) – Start time of the time period.

  • end (datetime.datetime) – End time of the time period.

  • processor (Processor | None, optional) – Optional Preprocessor to use. Defaults to None.

Returns:

Metadata per year, list of events in time period.

Return type:

ArchiveEventsData

async get_all_events(pvs: set[str], start: datetime.datetime, end: datetime.datetime, processor: epicsarchiver.retrieval.archiver_retrieval.processor.Processor | None = None) dict[str, list[epicsarchiver.retrieval.archive_event.ArchiveEvent]][source]

Get a list of events for every pv requested.

Makes all the calls to the archiver asynchronously, so some maybe made in parallel.

Parameters:
Returns:

Dictionary of pvs (keys) and events (values).

Return type:

dict[str, list[ArchiveEvent]]

async search(query: str, *, start: datetime.datetime | None = None, end: datetime.datetime | None = None, limit: int = 500) list[str][source]

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.

Parameters:
  • query (str) – A regex search string.

  • start (datetime.datetime | None) – Start time of the time period.

  • end (datetime.datetime | None) – End time of the time period.

  • limit (int) – 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]

Returns:

List of PV names found.

Return type:

list[str]