Skip to content

Commit

Permalink
silenced debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
DoKu88 committed Dec 16, 2024
1 parent 4c25957 commit 762c43d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions synth_sdk/tracing/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def load_signed_url(signed_url: str, dataset: Dataset, traces: List[SystemTrace]
else:
print(f"Successfully loaded signed URL Status Code: {response.status_code} Response: {response.text}, Signed URL: {signed_url}")

def send_system_traces_s3(dataset: Dataset, traces: List[SystemTrace], base_url: str, api_key: str):
def send_system_traces_s3(dataset: Dataset, traces: List[SystemTrace], base_url: str, api_key: str, verbose: bool = False):
# Create async function that contains all async operations
async def _async_operations():

upload_id, signed_url = await get_upload_id(base_url, api_key)
upload_id, signed_url = await get_upload_id(base_url, api_key, verbose)
load_signed_url(signed_url, dataset, traces)

token_url = f"{base_url}/v1/auth/token"
Expand All @@ -114,9 +114,10 @@ async def _async_operations():
signed_url = response.json()["signed_url"]
status = response.json()["status"]

print(f"Status: {status}")
print(f"Upload ID retrieved: {upload_id}")
print(f"Signed URL: {signed_url}")
if verbose:
print(f"Status: {status}")
print(f"Upload ID retrieved: {upload_id}")
print(f"Signed URL: {signed_url}")

return upload_id, signed_url
except requests.exceptions.HTTPError as e:
Expand All @@ -140,7 +141,7 @@ async def _async_operations():
loop = asyncio.get_event_loop()
return loop.run_until_complete(_async_operations())

async def get_upload_id(base_url: str, api_key: str):
async def get_upload_id(base_url: str, api_key: str, verbose: bool = False):
token_url = f"{base_url}/v1/auth/token"
token_response = requests.get(token_url, headers={"customer_specific_api_key": api_key})
token_response.raise_for_status()
Expand All @@ -157,8 +158,9 @@ async def get_upload_id(base_url: str, api_key: str):
response.raise_for_status()
upload_id = response.json()["upload_id"]
signed_url = response.json()["signed_url"]
print(f"Upload ID retrieved: {upload_id}")
print(f"Signed URL retrieved: {signed_url}")
if verbose:
print(f"Upload ID retrieved: {upload_id}")
print(f"Signed URL retrieved: {signed_url}")
return upload_id, signed_url
except requests.exceptions.HTTPError as e:
logging.error(f"HTTP error occurred: {e}")
Expand Down Expand Up @@ -388,6 +390,7 @@ def upload_helper(
traces=traces,
base_url="https://agent-learning.onrender.com",
api_key=api_key,
verbose=verbose,
)

if verbose:
Expand Down

0 comments on commit 762c43d

Please sign in to comment.