sailor.pai.alert

Retrieve Alert information from the alert re-use service.

Classes are provided for individual Alert as well as groups of Alerts (AlertSet).

class sailor.pai.alert.Alert(ac_json)[source]

Bases: PredictiveAssetInsightsEntity

PredictiveAssetInsights Alert Object.

Parameters

ac_json (dict) –

classmethod get_available_properties()

Return the available properties for this class.

property id

Return the ID of the object.

class sailor.pai.alert.AlertSet(elements)[source]

Bases: PredictiveAssetInsightsEntitySet

Class representing a group of Alerts.

as_df(columns=None, include_all_custom_properties=False)[source]

Return all information on the objects stored in the AlertSet as a pandas dataframe.

Parameters
  • columns (Optional[Iterable[str]]) – Select the columns (and their order) for the DataFrame.

  • include_all_custom_properties – If True, adds ALL custom properties attached to the alerts to the resulting DataFrame. This can only be used when all alerts in the AlertSet are of the same type.

filter(**kwargs)

Select a subset of the collection based on named filter criteria for the attributes of the elements.

All keyword arguments are concatenated as filters with OR operator, i.e., only one of the supplied filters must match for an entity to be selected.

Returns a new AssetcentralEntitySet object.

Return type

MasterDataEntitySet

plot_distribution(by=None, fill=None, dropna=False)

Plot the distribution of elements of a MasterDataEntitySet based on their properties.

This effectively creates a histogram with the number of elements per group on the y-axis, and the group (given by the by parameter) on the x-axis. Additionally, the fill colour of the bar can be used to distinguish a second dimension.

plot_overview()[source]

Plot an overview over all alerts in the set as a function of time.

Each alert will be shown by a point, on a y-scale representing the affected equipment and with a color representing the alert type. The size of the point is given by the count value. This value represents how many times the alert has occurred in the deduplication window specified by the alert type.

Example

Plot an overview over all alerts in the dataset “alert_set” by time:

alert_set.plot_overview()
sailor.pai.alert.create_alert(**kwargs)[source]

Create a new alert in the remote system.

Alerts are immutable. If the specified alert type uses a deduplication period, the remote system will not create a new alert but ONLY increase the counter for an existing alert on the same equipment within the deduplication period. This means (1) additional properties supplied are discarded and (2) this function will return the existing alert object as a response.

Parameters

**kwargs – Keyword arguments which names correspond to the available properties. Can also be used to supply custom fields (Z_*, z_*) used with the corresponding alert type: in this case the type of the field is not known to Sailor and therefore the value must be strictly given in the format defined by the type as defined by the remote API.

Returns

A new alert object as retrieved from PAI after the create succeeded.

Return type

Alert

Example

alert = create_alert(equipment_id=’123’, triggered_on=’2020-07-31T13:23:00Z’,

type=’PUMP_TEMP_WARN’, severity_code=5, indicator_id=’ic1’, indicator_group_id=’ig1’, template_id=’t1’)

sailor.pai.alert.find_alerts(*, extended_filters=(), **kwargs)[source]

Fetch Alerts from PredictiveAssetInsights (PAI) with the applied filters, return an AlertSet.

This method supports the common filter language explained at Filter Language.

Parameters
Return type

AlertSet

Examples

Get all Alerts with the type ‘MyAlertType’:

find_alerts(type='MyAlertType')

Get all Error(severity code=10) and Information(severity code=1) alerts:

find_equipment(severity_code=[10, 1])