Skip to content
Snippets Groups Projects
Commit 79e9e1b9 authored by DEBREUVE Eric's avatar DEBREUVE Eric
Browse files

fixed bad import, added error msg when no tensorflow, "uniform" error msging

parent 4c70fe5e
Branches main
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
from logger_36.constant.handler import HIDE_WHERE_KWARG
from logger_36.constant.logger import HIDE_WHERE_KWARG
from logger_36.instance import LOGGER
from logger_36.task.measure.chronos import ElapsedTime
......
......@@ -29,19 +29,30 @@
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
from logger_36.constant.handler import HIDE_WHERE_KWARG
import sys as sstm
from logger_36.constant.error import GPU_LOGGING_ERROR
from logger_36.constant.logger import HIDE_WHERE_KWARG
from logger_36.instance import LOGGER
try:
import tensorflow as tsfl
import tensorrt as tsrt
_GPU_LOGGING_ERROR = None
except ModuleNotFoundError:
tsfl = tsrt = None
_GPU_LOGGING_ERROR = GPU_LOGGING_ERROR
def LogGPURelatedDetails() -> None:
""""""
global _GPU_LOGGING_ERROR
if None in (tsfl, tsrt):
if _GPU_LOGGING_ERROR is not None:
print(_GPU_LOGGING_ERROR, file=sstm.stderr)
_GPU_LOGGING_ERROR = None
return
system_details = tsfl.sysconfig.get_build_info()
......
# Copyright CNRS/Inria/UniCA
# Contributor(s): Eric Debreuve (since 2023)
#
# eric.debreuve@cnrs.fr
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
GPU_LOGGING_ERROR = (
"GPU details cannot be logged because the Tensorflow and/or Tensorrt package(s) "
"(https://www.tensorflow.org/, https://developer.nvidia.com/tensorrt)"
"is/are not installed or not importable."
)
MEMORY_MEASURE_ERROR = (
"Memory usage cannot be shown because the Psutil package "
"(https://psutil.readthedocs.io/en/latest/)"
"is not installed or not importable."
)
MISSING_RICH_ERROR = (
"The Rich console handler is not available because the Rich package "
"(https://rich.readthedocs.io/en/stable/) "
"is not installed or not importable. "
"Falling back to the raw console."
)
......@@ -33,7 +33,3 @@ import typing as h
storage_units_h = h.Literal["b", "k", "m", "g", "a"]
STORAGE_UNITS: tuple[str, ...] = h.get_args(storage_units_h)
MEMORY_MEASURE_ERROR = (
"Cannot show memory usage: " 'Package "psutil" not installed or importable.'
)
......@@ -33,28 +33,24 @@ import logging as lggg
import sys as sstm
from pathlib import Path as path_t
from logger_36.catalog.handler.console import console_handler_t
from logger_36.catalog.handler.file import file_handler_t
from logger_36.catalog.handler.generic import generic_handler_t, interface_h
from logger_36.constant.error import MISSING_RICH_ERROR
from logger_36.constant.handler import HANDLER_CODES, handler_codes_h
from logger_36.instance import LOGGER
from logger_36.task.format.message import FormattedMessage
try:
from logger_36.catalog.handler.console_rich import console_rich_handler_t
_RICH_ERROR = None
_MISSING_RICH_ERROR = None
except ModuleNotFoundError:
from logger_36.catalog.handler.console import (
console_handler_t as console_rich_handler_t,
)
_RICH_ERROR = (
"The Rich console handler is not available, "
"probably because the Rich package "
"(https://rich.readthedocs.io/en/stable/index.html) "
"is not installed, or not loadable. "
"Falling back to the raw console."
)
from logger_36.catalog.handler.console import console_handler_t
from logger_36.catalog.handler.file import file_handler_t
from logger_36.catalog.handler.generic import generic_handler_t, interface_h
from logger_36.constant.handler import HANDLER_CODES, handler_codes_h
from logger_36.instance import LOGGER
from logger_36.task.format.message import FormattedMessage
_MISSING_RICH_ERROR = MISSING_RICH_ERROR
def AddGenericHandler(
......@@ -125,10 +121,10 @@ def AddRichConsoleHandler(
**kwargs,
) -> None:
""""""
global _RICH_ERROR
if _RICH_ERROR is not None:
print(_RICH_ERROR, file=sstm.stderr)
_RICH_ERROR = None
global _MISSING_RICH_ERROR
if _MISSING_RICH_ERROR is not None:
print(_MISSING_RICH_ERROR, file=sstm.stderr)
_MISSING_RICH_ERROR = None
if logger is None:
logger = LOGGER
......
......@@ -35,14 +35,16 @@ import sys as sstm
import typing as h
from logger_36.config.message import TIME_FORMAT, WHERE_FORMAT
from logger_36.constant.error import MEMORY_MEASURE_ERROR
from logger_36.constant.handler import HANDLER_CODES
from logger_36.constant.memory import MEMORY_MEASURE_ERROR
from logger_36.constant.message import NEXT_LINE_PROLOGUE
from logger_36.constant.record import HIDE_WHERE_ATTR, SHOW_WHERE_ATTR
from logger_36.task.format.message import FormattedMessage, MessageFormat
from logger_36.task.measure.chronos import TimeStamp
from logger_36.task.measure.memory import CanCheckMemory
_MEMORY_MEASURE_ERROR = MEMORY_MEASURE_ERROR
@dtcl.dataclass(slots=True, repr=False, eq=False)
class handler_extension_t:
......@@ -59,6 +61,8 @@ class handler_extension_t:
self, handler: lggg.Handler | None, level: int, formatter: lggg.Formatter | None
) -> None:
""""""
global _MEMORY_MEASURE_ERROR
if self.name in HANDLER_CODES:
raise ValueError(
FormattedMessage(
......@@ -73,7 +77,9 @@ class handler_extension_t:
if self.show_memory_usage and not CanCheckMemory():
self.show_memory_usage = False
print(MEMORY_MEASURE_ERROR, file=sstm.stderr)
if _MEMORY_MEASURE_ERROR is not None:
print(_MEMORY_MEASURE_ERROR, file=sstm.stderr)
_MEMORY_MEASURE_ERROR = None
handler.setLevel(level)
......
......@@ -29,4 +29,4 @@
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
__version__ = "2024.9"
__version__ = "2024.10"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment