flip_api.model_services.retrieve_model
Attributes
Functions
|
Load an SQL query from a file. |
Parse a query from the SQL result into an IQuery object. |
|
Parse files from the SQL result into a list of UploadedFiles objects. |
|
|
Retrieve a model by its ID. Returns the model details, including its status, associated files, and query. |
Module Contents
- flip_api.model_services.retrieve_model.RETRIEVE_MODEL_QUERY_FILE
- flip_api.model_services.retrieve_model.load_sql(file_path: str) str
Load an SQL query from a file.
- Parameters:
file_path (str) – Absolute or relative path to the
.sqlfile.- Returns:
The file contents.
- Return type:
str
- flip_api.model_services.retrieve_model.parse_query_from_result(query: Any) flip_api.domain.interfaces.model.IQuery
Parse a query from the SQL result into an IQuery object.
- Parameters:
query (Any) – Mapping-like row from the raw SQL result with
id,name, andquerykeys.- Returns:
The parsed query domain object.
- Return type:
- flip_api.model_services.retrieve_model.parse_files_from_result(files: Any, model_id: uuid.UUID) list[flip_api.db.models.main_models.UploadedFiles]
Parse files from the SQL result into a list of UploadedFiles objects.
- Parameters:
files (Any) – Iterable of mapping-like rows with
id,name,status,size,type, andtagkeys.model_id (UUID) – The model ID that each parsed file should be attributed to.
- Returns:
Parsed uploaded-file records. Rows with an unknown
statusare mapped toFileUploadStatus.ERROR.- Return type:
list[UploadedFiles]
- flip_api.model_services.retrieve_model.retrieve_model(model_id: uuid.UUID = Path(..., title='Model ID'), db: sqlmodel.Session = Depends(get_session), user_id: uuid.UUID = Depends(verify_token)) flip_api.domain.interfaces.model.IModelResponse
Retrieve a model by its ID. Returns the model details, including its status, associated files, and query.
The user must have access to the model to retrieve its details. If the model is not found or the user does not have access, an error is returned.
- Parameters:
model_id (UUID) – The ID of the model to retrieve.
db (Session) – The database session.
user_id (UUID) – The ID of the current user.
- Returns:
The details of the model, including its ID, name, description, status, query, and files.
- Return type:
- Raises:
HTTPException – If the user does not have access to the model or if the model is not found.
HTTPException – If there is a database error while retrieving the model.
HTTPException – If an unexpected error occurs during the retrieval process.