diff --git a/src/pypelines/__init__.py b/src/pypelines/__init__.py index 5a803c999e1c08fbc14fccfaa803a8e02ac723fb..3c6d080f950aebd969842dfad6c7d5f9a5b2d5c0 100644 --- a/src/pypelines/__init__.py +++ b/src/pypelines/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.0.61" +__version__ = "0.0.62" from . import loggs from .pipes import * diff --git a/src/pypelines/loggs.py b/src/pypelines/loggs.py index c7ad61ea8ac8ed131ea00912260342eab9b72d40..5f36e65928ced3aaa186750308c85a75846f36fb 100644 --- a/src/pypelines/loggs.py +++ b/src/pypelines/loggs.py @@ -13,10 +13,28 @@ from coloredlogs import ( ) from pathlib import Path +from typing import Protocol, Callable, cast + NAMELENGTH = 33 # global variable for formatting the length of the padding dedicated to name part in a logging record LEVELLENGTH = 9 # global variable for formatting the length of the padding dedicated to levelname part in a record +class PypelineLoggerProtocol(Protocol): + def save(self, msg, *args, **kwargs) -> None: ... + def load(self, msg, *args, **kwargs) -> None: ... + def note(self, msg, *args, **kwargs) -> None: ... + def start(self, msg, *args, **kwargs) -> None: ... + def end(self, msg, *args, **kwargs) -> None: ... + def header(self, msg, *args, **kwargs) -> None: ... + + +class PypelineLogger(logging.Logger, PypelineLoggerProtocol): + pass + + +getLogger = cast(Callable[[str], PypelineLogger], logging.getLogger) + + def enable_logging( filename: str | None = None, terminal_level: str = "NOTE", diff --git a/src/pypelines/pipelines.py b/src/pypelines/pipelines.py index 06e45338d45a896d4a7f89c9b734cdd2722cda65..a140325219b1ffb4e2a6cdc049f5c11a2e69c962 100644 --- a/src/pypelines/pipelines.py +++ b/src/pypelines/pipelines.py @@ -10,12 +10,7 @@ if TYPE_CHECKING: from .graphs import PipelineGraph -class PipelineType(Protocol): - - def __getattr__(self, name: str) -> "BasePipe": ... - - -class Pipeline(PipelineType): +class Pipeline: pipes: Dict[str, "BasePipe"] runner_backend_class = BaseTaskBackend