add id and name properties
This commit is contained in:
@@ -94,8 +94,8 @@ class PipelineTask(BaseTask):
|
|||||||
params: PipelineParams = PipelineParams(),
|
params: PipelineParams = PipelineParams(),
|
||||||
clock: BaseClock = SystemClock(),
|
clock: BaseClock = SystemClock(),
|
||||||
):
|
):
|
||||||
self.id: int = obj_id()
|
self._id: int = obj_id()
|
||||||
self.name: str = f"{self.__class__.__name__}#{obj_count(self)}"
|
self._name: str = f"{self.__class__.__name__}#{obj_count(self)}"
|
||||||
|
|
||||||
self._pipeline = pipeline
|
self._pipeline = pipeline
|
||||||
self._clock = clock
|
self._clock = clock
|
||||||
@@ -123,6 +123,14 @@ class PipelineTask(BaseTask):
|
|||||||
|
|
||||||
self._observer = TaskObserver(params.observers)
|
self._observer = TaskObserver(params.observers)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self) -> int:
|
||||||
|
return self._id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
def has_finished(self) -> bool:
|
def has_finished(self) -> bool:
|
||||||
"""Indicates whether the tasks has finished. That is, all processors
|
"""Indicates whether the tasks has finished. That is, all processors
|
||||||
have stopped.
|
have stopped.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from attr import dataclass
|
|||||||
from pipecat.frames.frames import Frame
|
from pipecat.frames.frames import Frame
|
||||||
from pipecat.observers.base_observer import BaseObserver
|
from pipecat.observers.base_observer import BaseObserver
|
||||||
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
||||||
from pipecat.utils.utils import cancel_task, create_task, obj_count
|
from pipecat.utils.utils import cancel_task, create_task, obj_count, obj_id
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -55,9 +55,18 @@ class TaskObserver(BaseObserver):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, observers: List[BaseObserver] = []):
|
def __init__(self, observers: List[BaseObserver] = []):
|
||||||
self.name: str = f"{self.__class__.__name__}#{obj_count(self)}"
|
self._id: int = obj_id()
|
||||||
|
self._name: str = f"{self.__class__.__name__}#{obj_count(self)}"
|
||||||
self._proxies: List[Proxy] = self._create_proxies(observers)
|
self._proxies: List[Proxy] = self._create_proxies(observers)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self) -> int:
|
||||||
|
return self._id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
async def stop(self):
|
async def stop(self):
|
||||||
"""Stops all proxy observer tasks."""
|
"""Stops all proxy observer tasks."""
|
||||||
for proxy in self._proxies:
|
for proxy in self._proxies:
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ class FrameProcessor:
|
|||||||
loop: asyncio.AbstractEventLoop | None = None,
|
loop: asyncio.AbstractEventLoop | None = None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
self.id: int = obj_id()
|
self._id: int = obj_id()
|
||||||
self.name = name or f"{self.__class__.__name__}#{obj_count(self)}"
|
self._name = name or f"{self.__class__.__name__}#{obj_count(self)}"
|
||||||
self._parent: "FrameProcessor" | None = None
|
self._parent: "FrameProcessor" | None = None
|
||||||
self._prev: "FrameProcessor" | None = None
|
self._prev: "FrameProcessor" | None = None
|
||||||
self._next: "FrameProcessor" | None = None
|
self._next: "FrameProcessor" | None = None
|
||||||
@@ -83,6 +83,14 @@ class FrameProcessor:
|
|||||||
# the exception to this rule. This create this task.
|
# the exception to this rule. This create this task.
|
||||||
self.__create_push_task()
|
self.__create_push_task()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self) -> int:
|
||||||
|
return self._id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def interruptions_allowed(self):
|
def interruptions_allowed(self):
|
||||||
return self._allow_interruptions
|
return self._allow_interruptions
|
||||||
|
|||||||
@@ -53,13 +53,21 @@ class BaseTransport(ABC):
|
|||||||
output_name: Optional[str] = None,
|
output_name: Optional[str] = None,
|
||||||
loop: Optional[asyncio.AbstractEventLoop] = None,
|
loop: Optional[asyncio.AbstractEventLoop] = None,
|
||||||
):
|
):
|
||||||
self.id: int = obj_id()
|
self._id: int = obj_id()
|
||||||
self.name = name or f"{self.__class__.__name__}#{obj_count(self)}"
|
self._name = name or f"{self.__class__.__name__}#{obj_count(self)}"
|
||||||
self._input_name = input_name
|
self._input_name = input_name
|
||||||
self._output_name = output_name
|
self._output_name = output_name
|
||||||
self._loop = loop or asyncio.get_running_loop()
|
self._loop = loop or asyncio.get_running_loop()
|
||||||
self._event_handlers: dict = {}
|
self._event_handlers: dict = {}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self) -> int:
|
||||||
|
return self._id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def input(self) -> FrameProcessor:
|
def input(self) -> FrameProcessor:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|||||||
Reference in New Issue
Block a user