Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
Signed-off-by: Teo <[email protected]>
  • Loading branch information
teocns committed Nov 29, 2024
1 parent 99a452a commit b7dd348
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion agentops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,4 @@ def flush():

print("@@@PROVIDER:" + str(id(provider)))
breakpoint()
return provider.force_flush() # !!
return provider.force_flush() # !!
6 changes: 3 additions & 3 deletions agentops/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def __init__(self, func=None, *, key=None, reentrant=False):
self.func = func
self.key = key
self.reentrant = reentrant

if func is not None: # @atomic case
self._wrapped = self._wrap(func)

Expand All @@ -427,7 +427,7 @@ def _wrap(self, func):
def wrapper(*args, **kwargs):
# Get instance for instance methods
instance = args[0] if args and not isinstance(args[0], type) else None

# Generate lock key
if callable(self.key) and instance:
# For instance-specific locks, use the key generator
Expand All @@ -439,7 +439,7 @@ def wrapper(*args, **kwargs):
# Get or create lock
with self._registry_lock:
if lock_key not in self._locks:
self._locks[lock_key] = threading.RLock() # THIS HAS TO BE A RLOCK NO MATTER WHAT
self._locks[lock_key] = threading.RLock() # THIS HAS TO BE A RLOCK NO MATTER WHAT
lock = self._locks[lock_key]

if not self.reentrant and lock._is_owned():
Expand Down
3 changes: 2 additions & 1 deletion agentops/session/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ class SessionProtocol(Protocol):
session_id: UUID

@property
def config(self) -> Configuration: ...
def config(self) -> Configuration:
...

state: SessionState

Expand Down
5 changes: 1 addition & 4 deletions tests/core_manual_tests/api_server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ def foo(x: str):
end_time = time.time()
execution_time = end_time - start_time

return {
"response": "Done",
"execution_time_seconds": round(execution_time, 3)
}
return {"response": "Done", "execution_time_seconds": round(execution_time, 3)}


if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion tests/session/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ def session(mock_req):

# Clear all sessions
agentops.end_all_sessions()

10 changes: 5 additions & 5 deletions tests/test_atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from agentops.singleton import singleton, conditional_singleton, clear_singletons


class TestAtomicDecorator:
def test_atomic_basic(self):
"""Test basic atomic operation"""
Expand Down Expand Up @@ -328,10 +329,9 @@ def run_generator():
for i in range(0, len(sequence), 5):
assert sequence[i : i + 5] == list(range(5)), "Generator sequence should be ordered"


def test_atomic_with_singleton(self):
"""Test atomic works with singleton classes"""

@singleton
class Counter:
def __init__(self):
Expand Down Expand Up @@ -364,7 +364,7 @@ def increment(self):

def test_atomic_with_conditional_singleton(self):
"""Test atomic works with conditional singletons"""

@conditional_singleton
class Counter:
def __init__(self):
Expand Down Expand Up @@ -406,7 +406,7 @@ def increment(self):

def test_atomic_with_class_instances(self):
"""Test atomic behavior across different instances of the same class"""

class Counter:
def __init__(self):
self.value = 0
Expand Down Expand Up @@ -449,4 +449,4 @@ def increment_shared(self):
t.join()

assert counter1.value == 100, "Counter1 should have its own count"
assert counter2.value == 100, "Counter2 should have its own count"
assert counter2.value == 100, "Counter2 should have its own count"
1 change: 0 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from agentops.singleton import singleton, conditional_singleton, clear_singletons

# ... existing tests ...

0 comments on commit b7dd348

Please sign in to comment.