-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy path__init__.py
More file actions
29 lines (25 loc) · 1.01 KB
/
__init__.py
File metadata and controls
29 lines (25 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from fastapi import HTTPException
import httpx
from nilai_common import AttestationReport
ATTESTATION_URL = "http://nilcc-attester/v2/report"
async def get_attestation_report(nonce: str) -> AttestationReport:
"""Get the attestation report"""
try:
async with httpx.AsyncClient() as client:
response: httpx.Response = await client.get(ATTESTATION_URL)
response_json = response.json()
return AttestationReport(
nonce=nonce,
gpu_attestation=response_json["gpu_token"],
cpu_attestation=response_json["report"],
verifying_key="", # Added later by the API
)
except httpx.HTTPStatusError as e:
raise HTTPException(
status_code=e.response.status_code,
detail=str("Error getting attestation report" + str(e)),
)
except Exception as e:
raise HTTPException(
status_code=500, detail=str("Error getting attestation report" + str(e))
)