Skip to content

Commit 3899957

Browse files
committed
clean up
1 parent 2dc3014 commit 3899957

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

sentience/cloud_tracing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,9 @@ def upload_one(seq: int, url: str) -> bool:
594594

595595
if response.status_code == 200:
596596
if self.logger:
597-
self.logger.info(f"Screenshot {seq} uploaded successfully ({image_size / 1024:.1f} KB)")
597+
self.logger.info(
598+
f"Screenshot {seq} uploaded successfully ({image_size / 1024:.1f} KB)"
599+
)
598600
return True
599601
else:
600602
error_msg = f"Screenshot {seq} upload failed: HTTP {response.status_code}"

sentience/snapshot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ async def _snapshot_via_extension_async(
410410
format_match = screenshot_data_url.split(";")[0].split("/")[-1]
411411
if format_match in ["jpeg", "jpg", "png"]:
412412
result["screenshot_format"] = "jpeg" if format_match in ["jpeg", "jpg"] else "png"
413-
413+
414414

415415
# Validate and parse with Pydantic
416416
snapshot_obj = Snapshot(**result)
@@ -460,7 +460,7 @@ async def _snapshot_via_api_async(
460460
""",
461461
raw_options,
462462
)
463-
463+
464464
# Extract screenshot from raw result (extension captures it, but API doesn't return it)
465465
screenshot_data_url = raw_result.get("screenshot")
466466
screenshot_format = None
@@ -521,7 +521,7 @@ async def _snapshot_via_api_async(
521521
format_match = screenshot_data_url.split(";")[0].split("/")[-1]
522522
if format_match in ["jpeg", "jpg", "png"]:
523523
screenshot_format = "jpeg" if format_match in ["jpeg", "jpg"] else "png"
524-
524+
525525
# Merge API result with local data
526526
snapshot_data = {
527527
"status": api_result.get("status", "success"),

sentience/tracer_factory.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def create_tracer(
7777
print(f"🔗 [Sentience] Attempting to initialize cloud tracing...")
7878
print(f" API URL: {api_url}/v1/traces/init")
7979
print(f" Run ID: {run_id}")
80-
80+
8181
response = requests.post(
8282
f"{api_url}/v1/traces/init",
8383
headers={"Authorization": f"Bearer {api_key}"},
@@ -134,7 +134,9 @@ def create_tracer(
134134
print(f"⚠️ [Sentience] Cloud init failed: HTTP {response.status_code}")
135135
try:
136136
error_data = response.json()
137-
error_msg = error_data.get("error") or error_data.get("message", "Unknown error")
137+
error_msg = error_data.get("error") or error_data.get(
138+
"message", "Unknown error"
139+
)
138140
print(f" Error: {error_msg}")
139141
if "tier" in error_msg.lower() or "subscription" in error_msg.lower():
140142
print(f" 💡 This may be a tier/subscription issue")

tests/test_cloud_tracing.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,21 @@ def post_side_effect(*args, **kwargs):
332332
compressed_data = trace_upload_call[1]["data"]
333333
decompressed_data = gzip.decompress(compressed_data)
334334
trace_content = decompressed_data.decode("utf-8")
335-
events = [json.loads(line) for line in trace_content.strip().split("\n") if line.strip()]
335+
events = [
336+
json.loads(line) for line in trace_content.strip().split("\n") if line.strip()
337+
]
336338

337339
snapshot_events = [e for e in events if e.get("type") == "snapshot"]
338340
assert len(snapshot_events) > 0, "Should have snapshot event"
339341

340342
for event in snapshot_events:
341343
data = event.get("data", {})
342-
assert "screenshot_base64" not in data, "screenshot_base64 should be removed from uploaded trace"
343-
assert "screenshot_format" not in data, "screenshot_format should be removed from uploaded trace"
344+
assert (
345+
"screenshot_base64" not in data
346+
), "screenshot_base64 should be removed from uploaded trace"
347+
assert (
348+
"screenshot_format" not in data
349+
), "screenshot_format should be removed from uploaded trace"
344350

345351
# Cleanup
346352
cache_dir = Path.home() / ".sentience" / "traces" / "pending"

0 commit comments

Comments
 (0)