Skip to content

Commit

Permalink
rf: establish abstract base class ResultHandler
Browse files Browse the repository at this point in the history
And `LegacyResultHandler` as its only implementation for now.
  • Loading branch information
mih committed Sep 10, 2024
1 parent 30def30 commit 2e2a59f
Showing 1 changed file with 48 additions and 2 deletions.
50 changes: 48 additions & 2 deletions datalad_next/patches/interface_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import json
import logging
import sys
from abc import (
ABC,
abstractmethod,
)
from functools import (
partial,
wraps,
Expand Down Expand Up @@ -58,7 +62,49 @@
lgr = logging.getLogger('datalad.interface.utils')


class ResultHandler:
class ResultHandler(ABC):
@abstractmethod
def return_results(self, get_results: Callable):
"""
"""

@abstractmethod
def log_result(self, result: dict) -> None:
"""
"""

@abstractmethod
def want_custom_result_summary(self, mode: str) -> bool:
"""
"""

@abstractmethod
def render_result(self, result: dict) -> None:
"""
"""

@abstractmethod
def render_result_summary(self) -> None:
"""
"""

@abstractmethod
def run_result_hooks(self, res) -> Generator[dict[str, Any], None, None]:
"""
"""

@abstractmethod
def transform_result(self, res) -> Generator[Any, None, None]:
"""
"""

@abstractmethod
def keep_result(self, res) -> bool:
"""
"""


class LegacyResultHandler(ResultHandler):
def __init__(
self,
interface: anInterface,
Expand Down Expand Up @@ -370,7 +416,7 @@ def eval_func(*args, **kwargs):
result_handler_cls = kwargs.pop('result_handler_cls', None)
if result_handler_cls is None:
# use default
result_handler_cls = ResultHandler
result_handler_cls = LegacyResultHandler

result_handler = result_handler_cls(
wrapped_class,
Expand Down

0 comments on commit 2e2a59f

Please sign in to comment.