File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -505,6 +505,29 @@ def _consume_chunk(chunk_obj: Any) -> int | None:
505505 pass
506506 return records
507507
508+ def fetch_model_version (
509+ self ,
510+ model_name : str ):
511+ try :
512+ w = WorkspaceClient (
513+ host = databricks_vars ["DATABRICKS_HOST_URL" ],
514+ google_service_account = gcs_vars ["GCP_SERVICE_ACCOUNT_EMAIL" ],
515+ )
516+ except Exception as e :
517+ LOGGER .exception (
518+ "Failed to create Databricks WorkspaceClient with host: %s and service account: %s" ,
519+ databricks_vars ["DATABRICKS_HOST_URL" ],
520+ gcs_vars ["GCP_SERVICE_ACCOUNT_EMAIL" ],
521+ )
522+ raise ValueError (f"setup_new_inst(): Workspace client creation failed: { e } " )
523+
524+ model_info = w .registered_models .list (
525+ full_name = model_name ,
526+ include_aliases = True ,
527+ )
528+
529+ return model_info
530+
508531 def get_key_for_file (
509532 self , mapping : Dict [str , Any ], file_name : str
510533 ) -> Optional [str ]:
Original file line number Diff line number Diff line change @@ -587,3 +587,21 @@ def trigger_inference_run(
587587 "output_valid" : False ,
588588 "framework" : query_result [0 ][0 ].framework ,
589589 }
590+
591+ @router .get (
592+ "/{inst_id}/models/{model_name}/get-model-versions"
593+ )
594+ def get_model_versions (
595+ model_name : str ,
596+ inst_id : str ,
597+ current_user : Annotated [BaseUser , Depends (get_current_active_user )],
598+ sql_session : Annotated [Session , Depends (get_session )],
599+ databricks_control : Annotated [DatabricksControl , Depends (DatabricksControl )],
600+ ) -> Any :
601+
602+ model_name = decode_url_piece (model_name )
603+ has_access_to_inst_or_err (inst_id , current_user )
604+
605+ model_version_info = databricks_control .fetch_model_version (model_name )
606+
607+ return model_version_info
You can’t perform that action at this time.
0 commit comments