From 9e11310a5857df79b4389a0d6051026973efc7b7 Mon Sep 17 00:00:00 2001 From: YolanFery Date: Tue, 3 Dec 2024 17:24:06 +0100 Subject: [PATCH] Renames --- openhexa/sdk/pipelines/log_level.py | 35 +++++++++++++++++++++++++++++ openhexa/sdk/pipelines/priority.py | 22 ------------------ 2 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 openhexa/sdk/pipelines/log_level.py delete mode 100644 openhexa/sdk/pipelines/priority.py diff --git a/openhexa/sdk/pipelines/log_level.py b/openhexa/sdk/pipelines/log_level.py new file mode 100644 index 0000000..e146e8d --- /dev/null +++ b/openhexa/sdk/pipelines/log_level.py @@ -0,0 +1,35 @@ +"""Log levels for the pipeline runs.""" +from enum import IntEnum + + +class LogLevel(IntEnum): + """ + Enum representing different log levels. + + - Attributes: + DEBUG (int): Debug level, value 0. + INFO (int): Info level, value 1. + WARNING (int): Warning level, value 2. + ERROR (int): Error level, value 3. + CRITICAL (int): Critical level, value 4. + + """ + + DEBUG = 0 + INFO = 1 + WARNING = 2 + ERROR = 3 + CRITICAL = 4 + + @classmethod + def parse_log_level(cls, value) -> "LogLevel": + """Parse a log level from a string or integer.""" + if isinstance(value, int) and 0 <= value <= 4: + return LogLevel(value) + if isinstance(value, str): + if value.isdigit(): + return cls.parse_log_level(int(value)) + value = value.upper() + if hasattr(cls, value): + return getattr(cls, value) + return cls.INFO diff --git a/openhexa/sdk/pipelines/priority.py b/openhexa/sdk/pipelines/priority.py deleted file mode 100644 index 23efef1..0000000 --- a/openhexa/sdk/pipelines/priority.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Priority log levels for the pipeline runs.""" -from enum import IntEnum - - -class Priority(IntEnum): - """ - Enum representing different priority log levels. - - - Attributes: - DEBUG (int): Debug level, value 0. - INFO (int): Info level, value 1. - WARNING (int): Warning level, value 2. - ERROR (int): Error level, value 3. - CRITICAL (int): Critical level, value 4. - - """ - - DEBUG = 0 - INFO = 1 - WARNING = 2 - ERROR = 3 - CRITICAL = 4