From 32a74cf1291d1a5cfbd9a88a4e73a4bb15c4b8d9 Mon Sep 17 00:00:00 2001 From: Mihika Dusad Date: Wed, 5 Feb 2025 17:56:49 -0500 Subject: [PATCH] added type-hinting to communication scripts --- src/utils/communication/comm_utils.py | 4 ++-- src/utils/communication/interface.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/communication/comm_utils.py b/src/utils/communication/comm_utils.py index e2155de5..4ceded5d 100644 --- a/src/utils/communication/comm_utils.py +++ b/src/utils/communication/comm_utils.py @@ -1,6 +1,6 @@ from enum import Enum from utils.communication.grpc.main import GRPCCommunication -from typing import Any, Dict, List, Tuple, TYPE_CHECKING +from typing import Any, Dict, Union, List, Tuple, TYPE_CHECKING # from utils.communication.mpi import MPICommUtils # from mpi4py import MPI @@ -54,7 +54,7 @@ def get_rank(self) -> int: "Rank not implemented for communication type", self.comm_type ) - def send(self, dest: str | int | List[str | int], data: Any, tag: int = 0): + def send(self, dest: Union[str, int, List[Union[str, int]]], data: Any, tag: int = 0): if isinstance(dest, list): for d in dest: self.comm.send(dest=int(d), data=data) diff --git a/src/utils/communication/interface.py b/src/utils/communication/interface.py index 8df3c067..b6c9a8c7 100644 --- a/src/utils/communication/interface.py +++ b/src/utils/communication/interface.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from typing import Any, List +from typing import Any, Union, List class CommunicationInterface(ABC): @@ -11,7 +11,7 @@ def initialize(self): pass @abstractmethod - def send(self, dest: str | int, data: Any): + def send(self, dest: Union[str, int], data: Any): pass @abstractmethod