Skip to content

Commit de25d4a

Browse files
Merge pull request #1290 from roboflow/fix/pass-headers-to-send-usage-payloads
Move call to build_roboflow_api_headers from payload_helpers to collector
2 parents bd67c86 + 7ce0569 commit de25d4a

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

inference/core/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.49.3"
1+
__version__ = "0.49.4"
22

33

44
if __name__ == "__main__":

inference/usage_tracking/collector.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@
3535
ROBOFLOW_INTERNAL_SERVICE_SECRET,
3636
)
3737
from inference.core.logger import logger
38+
from inference.core.roboflow_api import build_roboflow_api_headers
3839
from inference.core.version import __version__ as inference_version
39-
from inference.core.workflows.execution_engine.v1.compiler.entities import (
40-
CompiledWorkflow,
41-
)
4240

4341
from .config import TelemetrySettings, get_telemetry_settings
4442
from .decorator_helpers import (
@@ -55,7 +53,6 @@
5553
APIKeyHash,
5654
APIKeyUsage,
5755
ResourceCategory,
58-
ResourceDetails,
5956
ResourceID,
6057
SystemDetails,
6158
UsagePayload,
@@ -536,6 +533,9 @@ def _offload_to_api(self, payloads: List[APIKeyUsage]):
536533
api_usage_endpoint_url=self._settings.api_usage_endpoint_url,
537534
hashes_to_api_keys=hashes_to_api_keys,
538535
ssl_verify=ssl_verify,
536+
headers=build_roboflow_api_headers(
537+
explicit_headers={"Authorization": f"Bearer {api_key}"}
538+
),
539539
)
540540
if api_keys_hashes_failed:
541541
logger.debug(

inference/usage_tracking/payload_helpers.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
import requests
55

6-
from inference.core.roboflow_api import build_roboflow_api_headers
6+
# NOTE: This module is used in isolation, no imports from inference are allowed
7+
78

89
ResourceID = str
910
Usage = Union[DefaultDict[str, Any], Dict[str, Any]]
@@ -149,6 +150,7 @@ def send_usage_payload(
149150
api_usage_endpoint_url: str,
150151
hashes_to_api_keys: Optional[Dict[APIKeyHash, APIKey]] = None,
151152
ssl_verify: bool = False,
153+
headers: Optional[Dict[str, str]] = None,
152154
) -> Set[APIKeyHash]:
153155
hashes_to_api_keys = hashes_to_api_keys or {}
154156
api_keys_hashes_failed = set()
@@ -168,9 +170,6 @@ def send_usage_payload(
168170
if "api_key_hash" in workflow_payload:
169171
del workflow_payload["api_key_hash"]
170172
workflow_payload["api_key"] = api_key
171-
headers = build_roboflow_api_headers(
172-
explicit_headers={"Authorization": f"Bearer {api_key}"}
173-
)
174173
response = requests.post(
175174
api_usage_endpoint_url,
176175
json=complete_workflow_payloads,

0 commit comments

Comments
 (0)