Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
siyangqiu committed Jul 30, 2024
1 parent 92a1f52 commit 5459802
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions agentops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(
Expand Down
18 changes: 9 additions & 9 deletions agentops/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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):
Expand Down Expand Up @@ -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)):
Expand All @@ -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)):
Expand All @@ -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:
Expand Down Expand Up @@ -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__}
Expand All @@ -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
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 5459802

Please sign in to comment.