|
26 | 26 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
27 | 27 | # POSSIBILITY OF SUCH DAMAGE. |
28 | 28 | # ============================================================================= |
29 | | -from typing import Protocol, Any, Callable, overload, List, Union, Tuple |
| 29 | +from typing import Protocol, Any, Callable, List, Union, Tuple |
30 | 30 |
|
31 | 31 | import dask.array as da |
32 | 32 | import numpy as np |
33 | 33 | from distributed import Future, Client |
34 | 34 |
|
35 | 35 |
|
36 | | -class SlidingWindowInterface(Protocol): |
37 | | - Callback_args = Union[str, Tuple[str], Tuple[str, int]] # array_name, (array_name, ...), (array_name, window_size) |
38 | | - |
39 | | - class SlidingWindowCallbackInterface(Protocol): |
| 36 | +class SupportsSlidingWindow(Protocol): |
| 37 | + class Callback(Protocol): |
40 | 38 | def __call__(self, *window: List[da.Array], timestep: int) -> None: ... |
41 | 39 |
|
42 | | - class ExceptionHandlerInterface(Protocol): |
| 40 | + class ExceptionHandler(Protocol): |
43 | 41 | def __call__(self, array_name: str, exception: BaseException) -> None: ... |
44 | 42 |
|
45 | | - @overload |
46 | | - def register_sliding_window_callback(self, callback: SlidingWindowCallbackInterface, |
47 | | - array_name: str, *, window_size: int = 1, |
48 | | - exception_handler: ExceptionHandlerInterface) -> None: ... |
49 | | - |
50 | | - @overload |
51 | | - def register_sliding_window_callback(self, callback: SlidingWindowCallbackInterface, |
52 | | - *callback_args: Callback_args, |
53 | | - exception_handler: ExceptionHandlerInterface, |
54 | | - when='AND') -> None: ... |
| 43 | + def register_sliding_window_callback(self, |
| 44 | + callback: Callback, |
| 45 | + array_name: str, window_size: int, |
| 46 | + exception_handler: ExceptionHandler) -> str: ... |
55 | 47 |
|
56 | | - def register_sliding_window_callback(self, callback: SlidingWindowCallbackInterface, |
57 | | - *callback_args: Callback_args, |
58 | | - window_size: int = 1, |
59 | | - exception_handler: ExceptionHandlerInterface, |
60 | | - when: str = 'AND') -> str: ... |
| 48 | + def register_sliding_window_callbacks(self, |
| 49 | + callback: Callback, |
| 50 | + *callback_args: Union[str, Tuple[str], Tuple[str, int]], |
| 51 | + exception_handler: ExceptionHandler, |
| 52 | + when: str = 'AND') -> str: ... |
61 | 53 |
|
62 | | - def unregister_sliding_window_callback(self, *array_names: Callback_args) -> None: ... |
| 54 | + def unregister_sliding_window_callback(self, *array_names: Union[str, Tuple[str]]) -> None: ... |
63 | 55 |
|
64 | 56 |
|
65 | | -class GetArrayInterface(Protocol): |
| 57 | +class SupportsGetArray(Protocol): |
66 | 58 | def get_array(self, array_name: str, timeout=None) -> tuple[da.Array, int]: ... |
67 | 59 |
|
68 | 60 |
|
69 | | -class DeisaInterface(SlidingWindowInterface, GetArrayInterface, Protocol): |
| 61 | +class IDeisa(SupportsSlidingWindow, SupportsGetArray, Protocol): |
70 | 62 |
|
71 | 63 | def __init__(self, get_connection_info: Callable[[], Client], *args, **kwargs): ... |
72 | 64 |
|
73 | | - def set(self, name: str, data: Union[Future, object], chunked=False) -> None: ... |
| 65 | + def set(self, name: str, data: Union[Future, object], chunked: bool) -> None: ... |
74 | 66 |
|
75 | 67 | def delete(self, key: str) -> None: ... |
76 | 68 |
|
77 | 69 | def close(self) -> None: ... |
78 | 70 |
|
79 | 71 |
|
80 | | -class BridgeInterface(Protocol): |
| 72 | +class IBridge(Protocol): |
81 | 73 | def __init__(self, id: int, arrays_metadata: dict[str, dict], system_metadata: dict[str, Any], *args, **kwargs): ... |
82 | 74 |
|
83 | 75 | def send(self, array_name: str, data: np.ndarray, timestep: int, chunked: bool) -> None: ... |
|
0 commit comments