Skip to content

Commit 8305181

Browse files
committed
feat: added model deletion endpoint
1 parent bd6cafe commit 8305181

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/webapp/databricks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def fetch_model_version(self, catalog_name: str, inst_name: str, model_name: str
533533
latest_version = max(model_versions, key=lambda v: int(v.version))
534534

535535
return latest_version
536-
536+
537537
def delete_model(self, catalog_name: str, inst_name: str, model_name: str):
538538
schema = databricksify_inst_name(inst_name)
539539
model_name_path = f"{catalog_name}.{schema}_gold.{model_name}"

src/webapp/routers/models.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ def read_inst_model(
310310
"framework": query_result[0][0].framework,
311311
}
312312

313+
313314
@router.delete("/{inst_id}/models/{model_name}", response_model=ModelInfo)
314315
def delete_model(
315316
inst_id: str,
@@ -319,26 +320,23 @@ def delete_model(
319320
sql_session: Annotated[Session, Depends(get_session)],
320321
databricks_control: Annotated[DatabricksControl, Depends(DatabricksControl)],
321322
) -> Any:
322-
323323
transformed_model_name = str(decode_url_piece(model_name)).strip()
324324
has_access_to_inst_or_err(inst_id, current_user)
325325
model_owner_and_higher_or_err(current_user, "modify batch")
326326

327327
local_session.set(sql_session)
328328
sess = local_session.get()
329329

330-
query_result = (
331-
sess.execute(
332-
select(InstTable).where(
333-
InstTable.id == str_to_uuid(inst_id)))
334-
.all()
335-
)
330+
query_result = sess.execute(
331+
select(InstTable).where(InstTable.id == str_to_uuid(inst_id))
332+
).all()
336333

337334
model_list = sess.execute(
338-
select(ModelTable.where(
339-
ModelTable.name == str_to_uuid(model_name),
340-
ModelTable.inst_id == str_to_uuid(inst_id),
341-
)
335+
select(
336+
ModelTable.where(
337+
ModelTable.name == str_to_uuid(model_name),
338+
ModelTable.inst_id == str_to_uuid(inst_id),
339+
)
342340
)
343341
).scalar_one_or_none()
344342
if model_list is None:
@@ -362,6 +360,7 @@ def delete_model(
362360
"deleted_from_databricks": delete_from_databricks,
363361
}
364362

363+
365364
@router.get("/{inst_id}/models/{model_name}/runs", response_model=list[RunInfo])
366365
def read_inst_model_outputs(
367366
inst_id: str,

0 commit comments

Comments
 (0)