|
3 | 3 | import uuid |
4 | 4 | from datetime import datetime, date |
5 | 5 | from databricks.sdk import WorkspaceClient |
6 | | -from typing import Annotated, Any, Dict, List, cast, IO, Optional, Tuple |
| 6 | +from typing import Annotated, Any, Dict, List, cast, IO, Optional, Tuple, Sequence |
7 | 7 | from pydantic import BaseModel, Field |
8 | 8 | from fastapi import APIRouter, Depends, HTTPException, status, Response, Query |
9 | 9 | from fastapi.responses import FileResponse |
@@ -1771,7 +1771,16 @@ def get_model_cards( |
1771 | 1771 | ) |
1772 | 1772 |
|
1773 | 1773 | try: |
1774 | | - volume_path = f"/Volumes/staging_sst_01/{databricksify_inst_name(query_result[0][0].name)}_gold/gold_volume/model_cards/model-card-{model_name}.pdf" |
| 1774 | + env_vals: Sequence[str] = env_vars.get("ENV", []) |
| 1775 | + env = (env_vals[0] if env_vals else "").strip().upper() |
| 1776 | + SCHEMAS = {"DEV": "dev_sst_02", "STAGING": "staging_sst_01"} |
| 1777 | + if env not in SCHEMAS: |
| 1778 | + raise ValueError( |
| 1779 | + f"Unsupported ENV {env_vars.get('ENV')!r}; expected DEV or STAGING" |
| 1780 | + ) |
| 1781 | + env_schema = SCHEMAS[env] |
| 1782 | + |
| 1783 | + volume_path = f"/Volumes/{env_schema}/{databricksify_inst_name(query_result[0][0].name)}_gold/gold_volume/model_cards/model-card-{model_name}.pdf" |
1775 | 1784 | LOGGER.info(f"Attempting to download from {volume_path}") |
1776 | 1785 | response = w.files.download(volume_path) |
1777 | 1786 | stream = cast(IO[bytes], response.contents) |
|
0 commit comments