pipeline.src.shared_tasks.healthcheck

Functions

get_monitorfish_healthcheck(...)

Fetches healthcheck on Monitorfish healthcheck endpoint.

assert_positions_received_by_api_health(healthcheck[, ...])

Checks if the date_last_position_received_by_api of the input

assert_last_positions_flow_health(healthcheck[, ...])

Checks if the date_time of most recent date_last_position_updated_by_prefect is

assert_logbook_health(healthcheck[, utcnow, ...])

Checks if the date_logbook_message_received of in the input

Module Contents

pipeline.src.shared_tasks.healthcheck.get_monitorfish_healthcheck() src.entities.monitorfish_healthcheck.MonitorfishHealthcheck[source]

Fetches healthcheck on Monitorfish healthcheck endpoint.

Returns:

MonitorfishHealthcheck

pipeline.src.shared_tasks.healthcheck.assert_positions_received_by_api_health(healthcheck: src.entities.monitorfish_healthcheck.MonitorfishHealthcheck, utcnow: datetime.datetime = None, max_minutes_without_data: int = 10)[source]

Checks if the date_last_position_received_by_api of the input MonitorfishHealthcheck is within max_minutes_without_data minutes of utcnow.

Parameters:
  • healthcheck (MonitorfishHealthcheck) – MonitorfishHealthcheck to check.

  • utcnow (datetime, optional) – Date with which to compare the latest position’s reception date. If not supplied, the current server time is used. Defaults to None.

  • max_minutes_without_data (int, optional) – maximum number of minutes allow between date_position_received and utcnow. Defaults to 10.

Raises:

MonitorfishHealthError – If the most recent data received is older than max_minutes_without_data.

pipeline.src.shared_tasks.healthcheck.assert_last_positions_flow_health(healthcheck: src.entities.monitorfish_healthcheck.MonitorfishHealthcheck, utcnow: datetime.datetime = None, max_minutes_without_data: int = 10)[source]

Checks if the date_time of most recent date_last_position_updated_by_prefect is in the last max_minutes_without_data minutes in the input MonitorfishHealthcheck.

Parameters:
  • healthcheck (MonitorfishHealthcheck) – MonitorfishHealthcheck to check.

  • utcnow (datetime, optional) – Date with which to compare the latest last_position’s reception date. If not supplied, the current server time is used. Defaults to None.

  • max_minutes_without_data (int, optional) – Number of minutes above which an absence of data is considered an unhealthy. Defaults to 10.

Raises:

MonitorfishHealthError – If the most recent data received is older than max_minutes_without_data.

pipeline.src.shared_tasks.healthcheck.assert_logbook_health(healthcheck: src.entities.monitorfish_healthcheck.MonitorfishHealthcheck, utcnow: datetime.datetime = None, max_minutes_without_data: int = 20)[source]

Checks if the date_logbook_message_received of in the input MonitorfishHealthcheck is older than max_minutes_without_data minutes.

Parameters:
  • healthcheck (MonitorfishHealthcheck) – MonitorfishHealthcheck to check.

  • utcnow (datetime, optional) – Date with which to compare the date_logbook_message_received of the input healthcheck. If not supplied, the current server time is used. Defaults to None.

  • max_minutes_without_data (int, optional) – Number of minutes above which an absence of data is considered an unhealthy. Defaults to 20.

Raises:

MonitorfishHealthError – If the most recent data received is older than max_minutes_without_data.