Skip to content

Commit 366e1e9

Browse files
committed
fixed endpoint issues
1 parent fea2f9b commit 366e1e9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/webapp/routers/data.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import logging
1515
from sqlalchemy.exc import IntegrityError
1616
from ..config import databricks_vars, env_vars, gcs_vars
17-
from mlflow.exceptions import MlflowException
1817
import tempfile
1918
import pathlib
2019

@@ -1376,7 +1375,7 @@ def get_model_cards(
13761375
try:
13771376
volume_path = f"/Volumes/staging_sst_01/{query_result[0][0].name}_gold/gold_volume/model-card-{model_name}.pdf"
13781377
response = w.files.download(volume_path)
1379-
pdf_bytes = response.read()
1378+
pdf_bytes = response.contents.read() # pylint: disable=no-member
13801379

13811380
except Exception as e:
13821381
raise HTTPException(500, detail=f"Failed to fetch model card: {e}")
@@ -1385,6 +1384,9 @@ def get_model_cards(
13851384
tmp = tempfile.NamedTemporaryFile(suffix=".pdf", delete=False)
13861385
tmp.write(pdf_bytes)
13871386
tmp.flush()
1387+
13881388
return FileResponse(
1389-
tmp.name, filename=tmp.name.split("/")[-1], media_type="application/pdf"
1390-
)
1389+
tmp.name,
1390+
filename=pathlib.Path(tmp.name).name,
1391+
media_type="application/pdf",
1392+
)

0 commit comments

Comments
 (0)