|
33 | 33 | import traceback |
34 | 34 | import logging |
35 | 35 | from ..gcsdbutils import update_db_from_bucket |
| 36 | +from ..config import env_vars |
36 | 37 |
|
37 | 38 | from ..gcsutil import StorageControl |
38 | 39 |
|
@@ -601,9 +602,30 @@ def get_model_versions( |
601 | 602 | transformed_model_name = str(decode_url_piece(model_name)).strip() |
602 | 603 | has_access_to_inst_or_err(inst_id, current_user) |
603 | 604 |
|
| 605 | + local_session.set(sql_session) |
| 606 | + query_result = ( |
| 607 | + local_session.get() |
| 608 | + .execute(select(InstTable).where(InstTable.id == str_to_uuid(inst_id))) |
| 609 | + .all() |
| 610 | + ) |
| 611 | + if not query_result or len(query_result) == 0: |
| 612 | + raise HTTPException( |
| 613 | + status_code=status.HTTP_404_NOT_FOUND, |
| 614 | + detail="Institution not found.", |
| 615 | + ) |
| 616 | + if len(query_result) > 1: |
| 617 | + raise HTTPException( |
| 618 | + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, |
| 619 | + detail="Institution duplicates found.", |
| 620 | + ) |
| 621 | + |
604 | 622 | print(f"Initial model name = {model_name}") |
605 | 623 | print(f"Converted model name {transformed_model_name}") |
606 | 624 |
|
607 | | - model_version_info = databricks_control.fetch_model_version(transformed_model_name) |
| 625 | + model_version_info = databricks_control.fetch_model_version( |
| 626 | + catalog_name=env_vars["CATALOG_NAME"], |
| 627 | + inst_name=f"{query_result[0][0].name}", |
| 628 | + model_name=transformed_model_name, |
| 629 | + ) |
608 | 630 |
|
609 | 631 | return model_version_info |
0 commit comments