From ec4a695908f0c66a7fc68f1ceb21c98e5ea40e73 Mon Sep 17 00:00:00 2001 From: Braelyn Boynton Date: Thu, 13 Jun 2024 12:51:15 -0700 Subject: [PATCH] init on start session --- agentops/__init__.py | 12 ++++++++++-- tests/test_session.py | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/agentops/__init__.py b/agentops/__init__.py index 2bc45276c..1335f6a9c 100755 --- a/agentops/__init__.py +++ b/agentops/__init__.py @@ -126,7 +126,6 @@ def end_session( ) -@check_init def start_session( tags: Optional[List[str]] = None, config: Optional[Configuration] = None, @@ -140,7 +139,16 @@ def start_session( e.g. ["test_run"]. config: (Configuration, optional): Client configuration object """ - return Client().start_session(tags, config, inherited_session_id) + + try: + sess_result = Client().start_session(tags, config, inherited_session_id) + + global is_initialized + is_initialized = True + + return sess_result + except Exception: + pass @check_init diff --git a/tests/test_session.py b/tests/test_session.py index effe00fae..7148a0084 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -26,7 +26,6 @@ def setup_method(self): self.api_key = "random_api_key" self.event_type = "test_event_type" self.config = agentops.Configuration(api_key=self.api_key, max_wait_time=50) - agentops.init(api_key=self.api_key) def test_session(self, mock_req): agentops.start_session(config=self.config)