Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
siyangqiu committed Jul 30, 2024
1 parent 6def9e5 commit 92a1f52
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
16 changes: 13 additions & 3 deletions agentops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ def add_tags(self, tags: List[str]) -> None:
Args:
tags (List[str]): The list of tags to append.
"""
if not self.is_initialized:
return

# if a string and not a list of strings
if not (isinstance(tags, list) and all(isinstance(item, str) for item in tags)):
Expand All @@ -142,7 +144,9 @@ def add_tags(self, tags: List[str]) -> None:

session = self._safe_get_session()
if session is None:
return
return logger.warning(
"Could not add tags. Start a session by calling agentops.start_session()."
)

session.add_tags(tags=tags)

Expand All @@ -155,11 +159,15 @@ def set_tags(self, tags: List[str]) -> None:
Args:
tags (List[str]): The list of tags to set.
"""
if not self.is_initialized:
return

session = self._safe_get_session()

if session is None:
return
return logger.warning(
"Could not set tags. Start a session by calling agentops.start_session()."
)
else:
session.set_tags(tags=tags)

Expand All @@ -184,7 +192,9 @@ def record(self, event: Union[Event, ErrorEvent]) -> None:

session = self._safe_get_session()
if session is None:
return logger.error("Could not record event. No session.")
return logger.error(
"Could not record event. Start a session by calling agentops.start_session()."
)
session.record(event)

def start_session(
Expand Down
1 change: 0 additions & 1 deletion agentops/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from .log_config import logger
from uuid import UUID
import os
from importlib.metadata import version

ao_instances = {}
Expand Down
1 change: 0 additions & 1 deletion agentops/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import requests

from .exceptions import ApiServerException
from .log_config import logger

JSON_HEADER = {"Content-Type": "application/json; charset=UTF-8", "Accept": "*/*"}

Expand Down

0 comments on commit 92a1f52

Please sign in to comment.