Initial commit: 2125_GCE project
This commit is contained in:
Regular → Executable
+25
-12
@@ -136,20 +136,33 @@ class FedMartAdapter:
|
||||
def _send_to_fedmart(self, telemetry: Dict[str, Any]) -> bool:
|
||||
"""Send telemetry to FedMart ingestion endpoint.
|
||||
|
||||
In production, this would use requests or httpx.
|
||||
For now, it's a stub.
|
||||
Posts to local server at http://localhost:8000/fedmart/ingest/xic
|
||||
"""
|
||||
# TODO: implement actual HTTP POST
|
||||
# response = requests.post(f"{self.endpoint}/xic", json=telemetry)
|
||||
# return response.status_code == 202
|
||||
print(f"[FEDMART] Would POST telemetry to {self.endpoint}/xic")
|
||||
return True
|
||||
try:
|
||||
import requests
|
||||
response = requests.post(
|
||||
"http://localhost:8000/fedmart/ingest/xic",
|
||||
json=telemetry,
|
||||
timeout=2
|
||||
)
|
||||
return response.status_code in (200, 202, 204)
|
||||
except Exception as e:
|
||||
print(f"[FEDMART] Error sending telemetry: {e}")
|
||||
return False
|
||||
|
||||
def _send_spec_to_fedmart(self, spec_map: Dict[str, Any]) -> bool:
|
||||
"""Send spec map to FedMart spec registration endpoint."""
|
||||
# TODO: implement actual HTTP POST
|
||||
print(f"[FEDMART] Would POST spec map to {self.endpoint}/spec_map")
|
||||
return True
|
||||
try:
|
||||
import requests
|
||||
response = requests.post(
|
||||
self.endpoint + "/spec_map",
|
||||
json=spec_map,
|
||||
timeout=2
|
||||
)
|
||||
return response.status_code in (200, 202, 204)
|
||||
except Exception as e:
|
||||
print(f"[FEDMART] Error sending spec map: {e}")
|
||||
return False
|
||||
|
||||
def _generate_run_id(self) -> str:
|
||||
"""Generate a unique run ID."""
|
||||
@@ -168,11 +181,11 @@ class FedMartAdapter:
|
||||
_adapter_instance: Optional[FedMartAdapter] = None
|
||||
|
||||
|
||||
def get_adapter(local_mode: bool = True) -> FedMartAdapter:
|
||||
def get_adapter(local_mode: bool = False) -> FedMartAdapter:
|
||||
"""Get or create the global FedMart adapter instance.
|
||||
|
||||
Args:
|
||||
local_mode: If True, buffer telemetry locally (default)
|
||||
local_mode: If True, buffer telemetry locally. Default False sends to server.
|
||||
|
||||
Returns:
|
||||
FedMartAdapter singleton
|
||||
|
||||
Reference in New Issue
Block a user