Skip to content

Commit

Permalink
Merge pull request #903 from roboflow/fix/usage-collector-fps
Browse files Browse the repository at this point in the history
Fix usage collector fps
  • Loading branch information
grzegorz-roboflow authored Dec 20, 2024
2 parents 2a811db + 7787f5b commit 03494f6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions inference/usage_tracking/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def empty_usage_dict(exec_session_id: str) -> APIKeyUsage:
usage_dict["roboflow_service_name"] = ROBOFLOW_INTERNAL_SERVICE_NAME

return defaultdict( # api_key_hash
lambda: defaultdict(lambda: usage_dict) # category:resource_id
lambda: defaultdict(lambda: {**usage_dict}) # category:resource_id
)

def _dump_usage_queue_no_lock(self) -> List[APIKeyUsage]:
Expand Down Expand Up @@ -345,12 +345,10 @@ def _update_usage_payload(
source_usage["timestamp_start"] = time.time_ns()
source_usage["timestamp_stop"] = time.time_ns()
source_usage["processed_frames"] += frames if not inference_test_run else 0
source_usage["fps"] = (
round(fps, 2) if isinstance(fps, numbers.Number) else 0
)
source_usage["source_duration"] += (
frames / fps if fps and not inference_test_run else 0
)
source_usage["fps"] = fps if isinstance(fps, numbers.Number) else 0
source_usage["category"] = category
source_usage["resource_id"] = resource_id
source_usage["resource_details"] = json.dumps(resource_details)
Expand Down

0 comments on commit 03494f6

Please sign in to comment.