Skip to content

Commit

Permalink
bypass request_mock
Browse files Browse the repository at this point in the history
  • Loading branch information
bboynton97 committed Aug 5, 2024
1 parent 0754e57 commit e31624b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions agentops/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import json
import inspect
from typing import Union
import requests
import http.client
import json
from importlib.metadata import version, PackageNotFoundError

from .log_config import logger
Expand Down Expand Up @@ -152,10 +153,15 @@ def get_agentops_version():


def check_agentops_update():
response = requests.get("https://pypi.org/pypi/agentops/json")

if response.status_code == 200:
latest_version = response.json()["info"]["version"]
# using http.client to avoid this call being caught by requests_mock on tests
conn = http.client.HTTPSConnection("pypi.org")
conn.request("GET", "/pypi/agentops/json")
response = conn.getresponse()
data = response.read().decode()
json_data = json.loads(data)

if response.status == 200:
latest_version = json_data["info"]["version"]

try:
current_version = version("agentops")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_record_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests_mock
import time
import agentops
from agentops.decorators import record_tool
from agentops import record_tool
from datetime import datetime

from agentops.helpers import clear_singletons
Expand Down

0 comments on commit e31624b

Please sign in to comment.