File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414import logging
1515from sqlalchemy .exc import IntegrityError
1616from ..config import databricks_vars , env_vars , gcs_vars
17- from mlflow .exceptions import MlflowException
1817import tempfile
1918import 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+ )
You can’t perform that action at this time.
0 commit comments