From 7fa1584ee33ddda670e551d2274fc81fc3f4782c Mon Sep 17 00:00:00 2001 From: Mesh Date: Thu, 5 Jun 2025 09:46:14 -0500 Subject: [PATCH 1/3] feat: added option for api auth --- src/webapp/databricks.py | 7 +++++-- src/webapp/routers/data.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/webapp/databricks.py b/src/webapp/databricks.py index 735e4596..8acb3be4 100644 --- a/src/webapp/databricks.py +++ b/src/webapp/databricks.py @@ -202,7 +202,7 @@ def delete_inst(self, inst_name: str) -> None: def fetch_table_data( self, catalog_name: str, - schema_name: str, + inst_name: str, table_name: str, warehouse_id: str, limit: int = 1000, @@ -221,7 +221,10 @@ def fetch_table_data( raise ValueError(f"Failed to initialize WorkspaceClient: {e}") # Construct the fully qualified table name - fully_qualified_table = f"`{catalog_name}`.`{schema_name}`.`{table_name}`" + schema_name = databricksify_inst_name(inst_name) + fully_qualified_table = ( + f"`{catalog_name}`.`{schema_name}__silver`.`{table_name}`" + ) sql_query = f"SELECT * FROM {fully_qualified_table} LIMIT {limit}" try: diff --git a/src/webapp/routers/data.py b/src/webapp/routers/data.py index 4208ce66..16bf145b 100644 --- a/src/webapp/routers/data.py +++ b/src/webapp/routers/data.py @@ -1077,7 +1077,7 @@ def get_top_features( dbc = DatabricksControl() rows = dbc.fetch_table_data( catalog_name=env_vars["CATALOG_NAME"], - schema_name=f"{query_result[0][0].name}_silver", + inst_name=f"{query_result[0][0].name}", table_name=f"sample_inference_{run_id}_features_with_most_impact", warehouse_id=env_vars["SQL_WAREHOUSE_ID"], limit=500, From 127cb12bfae1cb15a9fecab031274777b9ca45cb Mon Sep 17 00:00:00 2001 From: Mesh Date: Thu, 5 Jun 2025 09:52:23 -0500 Subject: [PATCH 2/3] feat: added option for api auth --- src/webapp/routers/data.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/webapp/routers/data.py b/src/webapp/routers/data.py index 16bf145b..720a155d 100644 --- a/src/webapp/routers/data.py +++ b/src/webapp/routers/data.py @@ -1121,7 +1121,7 @@ def get_support_overview( dbc = DatabricksControl() rows = dbc.fetch_table_data( catalog_name=env_vars["CATALOG_NAME"], - schema_name=f"{query_result[0][0].name}_silver", + inst_name=f"{query_result[0][0].name}", table_name=f"sample_inference_{run_id}_support_overview", warehouse_id=env_vars["SQL_WAREHOUSE_ID"], limit=500, @@ -1164,7 +1164,7 @@ def get_feature_value( dbc = DatabricksControl() rows = dbc.fetch_table_data( catalog_name=env_vars["CATALOG_NAME"], - schema_name=f"{query_result[0][0].name}_silver", + inst_name=f"{query_result[0][0].name}", table_name=f"sample_inference_{run_id}_shap_feature_importance", warehouse_id=env_vars["SQL_WAREHOUSE_ID"], limit=500, @@ -1207,7 +1207,7 @@ def get_confusion_matrix( dbc = DatabricksControl() rows = dbc.fetch_table_data( catalog_name=env_vars["CATALOG_NAME"], - schema_name=f"{query_result[0][0].name}_silver", + inst_name=f"{query_result[0][0].name}", table_name=f"sample_training_{run_id}_confusion_matrix", warehouse_id=env_vars["SQL_WAREHOUSE_ID"], limit=500, @@ -1250,7 +1250,7 @@ def get_roc_curve( dbc = DatabricksControl() rows = dbc.fetch_table_data( catalog_name=env_vars["CATALOG_NAME"], - schema_name=f"{query_result[0][0].name}_silver", + inst_name=f"{query_result[0][0].name}", table_name=f"sample_training_{run_id}_roc_curve", warehouse_id=env_vars["SQL_WAREHOUSE_ID"], limit=500, From 5bd7474b65cbea386d974c67028a39baa44ded69 Mon Sep 17 00:00:00 2001 From: Mesh Date: Thu, 5 Jun 2025 09:55:51 -0500 Subject: [PATCH 3/3] feat: added option for api auth --- src/webapp/routers/data.py | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/webapp/routers/data.py b/src/webapp/routers/data.py index 720a155d..c93d621a 100644 --- a/src/webapp/routers/data.py +++ b/src/webapp/routers/data.py @@ -1023,28 +1023,6 @@ def get_upload_url( raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(ve)) -# Get SHAP Values for Inference -@router.get("/inference/test") -def test() -> Any: - """Returns a signed URL for uploading data to a specific institution.""" - # raise error at this level instead bc otherwise it's getting wrapped as a 200 - - try: - dbc = DatabricksControl() - rows = dbc.fetch_table_data( - catalog_name="dev_sst_02", - schema_name="default", - table_name="test_dataset", - warehouse_id="28e1cbabfe6deb87", - limit=500, - ) - - return rows - except ValueError as ve: - # Return a 400 error with the specific message from ValueError - raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(ve)) - - # Get SHAP Values for Inference @router.get("/{inst_id}/inference/top-features/{run_id}", response_model=str) def get_top_features(