Skip to content

Commit

Permalink
Code format
Browse files Browse the repository at this point in the history
  • Loading branch information
lidongze0629 committed May 16, 2024
1 parent 36f4417 commit ad04bd3
Show file tree
Hide file tree
Showing 26 changed files with 370 additions and 692 deletions.
4 changes: 2 additions & 2 deletions flex/coordinator/gs_flex_coordinator/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
level=logging.INFO,
)

from gs_flex_coordinator.core.client_wrapper import client_wrapper
from gs_flex_coordinator.core.utils import handle_api_exception
from gs_flex_coordinator.core.client_wrapper import client_wrapper # noqa: F401, E402
from gs_flex_coordinator.core.utils import handle_api_exception # noqa: F401, E402
21 changes: 13 additions & 8 deletions flex/coordinator/gs_flex_coordinator/core/alert/alert_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@
import logging
import os
import pickle
from typing import List, Union
from typing import List
from typing import Union

from gs_flex_coordinator.core.alert.alert_receiver import DingTalkReceiver
from gs_flex_coordinator.core.alert.builtin_rules import \
init_builtin_alert_rules
from gs_flex_coordinator.core.alert.message_collector import \
AlertMessageCollector
from gs_flex_coordinator.core.alert.builtin_rules import init_builtin_alert_rules
from gs_flex_coordinator.core.alert.message_collector import AlertMessageCollector
from gs_flex_coordinator.core.config import ALERT_WORKSPACE
from gs_flex_coordinator.core.scheduler import schedule
from gs_flex_coordinator.core.utils import decode_datetimestr, encode_datetime
from gs_flex_coordinator.models import AlertMessage, AlertReceiver, AlertRule
from gs_flex_coordinator.core.utils import decode_datetimestr
from gs_flex_coordinator.core.utils import encode_datetime
from gs_flex_coordinator.models import AlertMessage
from gs_flex_coordinator.models import AlertReceiver
from gs_flex_coordinator.models import AlertRule


class AlertManager(object):
Expand Down Expand Up @@ -146,7 +148,10 @@ def list_alert_messages(
return rlt

def update_alert_messages(
self, messages: List[AlertMessage], batch_status: str, batch_delete: bool
self,
messages: List[AlertMessage],
batch_status: str,
batch_delete: bool,
):
for message in messages:
date = decode_datetimestr(message.trigger_time)
Expand Down
6 changes: 4 additions & 2 deletions flex/coordinator/gs_flex_coordinator/core/alert/alert_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

import datetime
import logging
from abc import ABCMeta, abstractmethod
from abc import ABCMeta
from abc import abstractmethod

from gs_flex_coordinator.core.alert.alert_message import AlertMessage
from gs_flex_coordinator.core.scheduler import cancel_job, schedule
from gs_flex_coordinator.core.scheduler import cancel_job
from gs_flex_coordinator.core.scheduler import schedule


class AlertRule(metaclass=ABCMeta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

from gs_flex_coordinator.core import client_wrapper
from gs_flex_coordinator.core.alert.alert_rule import AlertRule
from gs_flex_coordinator.core.alert.message_collector import \
AlertMessageCollector
from gs_flex_coordinator.core.config import CLUSTER_TYPE, SOLUTION
from gs_flex_coordinator.core.alert.message_collector import AlertMessageCollector
from gs_flex_coordinator.core.config import CLUSTER_TYPE
from gs_flex_coordinator.core.config import SOLUTION


class HighDiskUtilizationAlert(AlertRule):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

from gs_flex_coordinator.core.alert.alert_message import AlertMessage
from gs_flex_coordinator.core.config import ALERT_WORKSPACE
from gs_flex_coordinator.core.scheduler import cancel_job, schedule
from gs_flex_coordinator.core.scheduler import cancel_job
from gs_flex_coordinator.core.scheduler import schedule
from gs_flex_coordinator.core.utils import decode_datetimestr


Expand Down Expand Up @@ -59,7 +60,9 @@ def _pickle_messages_impl(self):
self.dump_to_disk()
except Exception as e:
logging.warn(
"Failed to dump alert message on date %s: %s", str(self._date), str(e)
"Failed to dump alert message on date %s: %s",
str(self._date),
str(e),
)

def _try_to_recover_from_disk(self):
Expand Down Expand Up @@ -109,7 +112,8 @@ def clean(self):
cancel_job(self._pickle_messages_job, delete_scheduler=True)
self._pickle_messages_job = None
logging.info(
"%s: current alert message collector cleaned", str(self._date)
"%s: current alert message collector cleaned",
str(self._date),
)
except: # noqa: E722, B110
pass
Expand Down

0 comments on commit ad04bd3

Please sign in to comment.