Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement alerts monitoring #175

Merged
merged 5 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
520 changes: 255 additions & 265 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions python/jaeger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# encoding: utf-8
# isort: skip_file

from __future__ import annotations

import logging
import os
from typing import Union
from typing import TYPE_CHECKING
import warnings

from sdsstools import get_config, get_logger, get_package_version
from sdsstools.configuration import __ENVVARS__

from .exceptions import JaegerUserWarning

if TYPE_CHECKING:
from .actor import JaegerActor


NAME = "jaeger"

Expand Down Expand Up @@ -52,7 +57,7 @@ def start_file_loggers(start_log=True, start_can=True):
can_log.start_file_logger(os.path.join(log_dir, "can.log"))


actor_instance = None
actor_instance: JaegerActor | None = None


from .can import *
Expand Down
1 change: 1 addition & 0 deletions python/jaeger/actor/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
JaegerCommandType = Command[JaegerActor]


from .alerts import *
from .can import *
from .chiller import *
from .configuration import *
Expand Down
42 changes: 42 additions & 0 deletions python/jaeger/actor/commands/alerts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# @Author: José Sánchez-Gallego (gallegoj@uw.edu)
# @Date: 2022-01-27
# @Filename: chiller.py
# @License: BSD 3-clause (http://www.opensource.org/licenses/BSD-3-Clause)

from __future__ import annotations

from typing import TYPE_CHECKING

from . import JaegerCommandType, command_parser


if TYPE_CHECKING:
from jaeger import FPS


__all__ = ["alerts"]


@command_parser.group()
def alerts(*args):
"""Manages the alerts system."""

pass


@alerts.command()
async def status(command: JaegerCommandType, fps: FPS):
"""Shows the status of the alerts."""

return command.finish(message={k: int(v) for k, v in fps.alerts.keywords.items()})


@alerts.command()
async def reset(command: JaegerCommandType, fps: FPS):
"""Clears all the alerts. Needed after certain alerts have been raised."""

fps.alerts.reset()
return command.finish(message={k: int(v) for k, v in fps.alerts.keywords.items()})
8 changes: 8 additions & 0 deletions python/jaeger/actor/commands/chiller.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# @Author: José Sánchez-Gallego (gallegoj@uw.edu)
# @Date: 2022-01-27
# @Filename: chiller.py
# @License: BSD 3-clause (http://www.opensource.org/licenses/BSD-3-Clause)

from __future__ import annotations

import asyncio
Expand Down
3 changes: 2 additions & 1 deletion python/jaeger/actor/commands/positioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ async def initialise(command, fps, positioner_id, datums=False):

@jaeger_parser.command()
@click.argument("POSITIONERS", type=int, nargs=-1, required=False)
async def status(command, fps, positioners):
async def status(command: JaegerCommandType, fps: FPS, positioners):
"""Reports the position and status bit of a list of positioners."""

positioner_ids = positioners or list(fps.positioners.keys())
Expand All @@ -277,6 +277,7 @@ async def status(command, fps, positioners):
command.info(locked=fps.locked)
command.info(n_positioners=len(fps.positioners))
command.info(fps_status=f"0x{fps.status.value:x}")
command.info(message={k: int(v) for k, v in fps.alerts.keywords.items()})

try:
await fps.update_status(positioner_ids=0)
Expand Down