From 5459802a455a617c9acc2fec9d2e50ed37abf08e Mon Sep 17 00:00:00 2001 From: Shawn Qiu Date: Tue, 30 Jul 2024 15:08:58 -0700 Subject: [PATCH] review --- agentops/client.py | 3 +-- agentops/session.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/agentops/client.py b/agentops/client.py index 4ba043c8..e4e2eed0 100644 --- a/agentops/client.py +++ b/agentops/client.py @@ -217,7 +217,6 @@ def start_session( if inherited_session_id is not None: try: session_id = UUID(inherited_session_id) - return Client().start_session(inherited_session_id=inherited_session_id) except ValueError: return logger.warning(f"Invalid session id: {inherited_session_id}") else: @@ -234,7 +233,7 @@ def start_session( config=self._config, ) - if not session.running: + if not session.is_running: return logger.error("Failed to start session") logger.info( diff --git a/agentops/session.py b/agentops/session.py index 4d034ab4..4555c835 100644 --- a/agentops/session.py +++ b/agentops/session.py @@ -61,8 +61,8 @@ def __init__( self.thread.daemon = True self.thread.start() - self.running = self._start_session() - if self.running == False: + self.is_running = self._start_session() + if self.is_running == False: self.stop_flag.set() self.thread.join(timeout=1) @@ -82,7 +82,7 @@ def end_session( video: Optional[str] = None, ) -> Union[Decimal, None]: - if not self.running: + if not self.is_running: return if not any(end_state == state.value for state in EndState): @@ -149,7 +149,7 @@ def add_tags(self, tags: List[str]) -> None: Args: tags (List[str]): The list of tags to append. """ - if not self.running: + if not self.is_running: return if not (isinstance(tags, list) and all(isinstance(item, str) for item in tags)): @@ -166,7 +166,7 @@ def add_tags(self, tags: List[str]) -> None: self._update_session() def set_tags(self, tags): - if not self.running: + if not self.is_running: return if not (isinstance(tags, list) and all(isinstance(item, str) for item in tags)): @@ -177,7 +177,7 @@ def set_tags(self, tags): self._update_session() def record(self, event: Union[Event, ErrorEvent]): - if not self.running: + if not self.is_running: return if isinstance(event, Event): if not event.end_timestamp or event.init_timestamp == event.end_timestamp: @@ -253,7 +253,7 @@ def _start_session(self): return True def _update_session(self) -> None: - if not self.running: + if not self.is_running: return with self.lock: payload = {"session": self.__dict__} @@ -268,7 +268,7 @@ def _update_session(self) -> None: return logger.error(f"Could not update session - {e}") def _flush_queue(self) -> None: - if not self.running: + if not self.is_running: return with self.lock: queue_copy = copy.deepcopy(self.queue) # Copy the current items @@ -303,7 +303,7 @@ def _run(self) -> None: self._flush_queue() def create_agent(self, name, agent_id): - if not self.running: + if not self.is_running: return if agent_id is None: agent_id = str(uuid4())