flip_api.model_services.retrieve_model ====================================== .. py:module:: flip_api.model_services.retrieve_model Attributes ---------- .. autoapisummary:: flip_api.model_services.retrieve_model.RETRIEVE_MODEL_QUERY_FILE Functions --------- .. autoapisummary:: flip_api.model_services.retrieve_model.load_sql flip_api.model_services.retrieve_model.parse_query_from_result flip_api.model_services.retrieve_model.parse_files_from_result flip_api.model_services.retrieve_model.retrieve_model Module Contents --------------- .. py:data:: RETRIEVE_MODEL_QUERY_FILE .. py:function:: load_sql(file_path: str) -> str Load an SQL query from a file. :param file_path: Absolute or relative path to the ``.sql`` file. :type file_path: str :returns: The file contents. :rtype: str .. py:function:: parse_query_from_result(query: Any) -> flip_api.domain.interfaces.model.IQuery Parse a query from the SQL result into an IQuery object. :param query: Mapping-like row from the raw SQL result with ``id``, ``name``, and ``query`` keys. :type query: Any :returns: The parsed query domain object. :rtype: IQuery .. py:function:: 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. :param files: Iterable of mapping-like rows with ``id``, ``name``, ``status``, ``size``, ``type``, and ``tag`` keys. :type files: Any :param model_id: The model ID that each parsed file should be attributed to. :type model_id: UUID :returns: Parsed uploaded-file records. Rows with an unknown ``status`` are mapped to :attr:`FileUploadStatus.ERROR`. :rtype: list[UploadedFiles] .. py:function:: 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. :param model_id: The ID of the model to retrieve. :type model_id: UUID :param db: The database session. :type db: Session :param user_id: The ID of the current user. :type user_id: UUID :returns: The details of the model, including its ID, name, description, status, query, and files. :rtype: IModelResponse :raises HTTPException: If the user does not have access to the model or if the model is not found. :raises HTTPException: If there is a database error while retrieving the model. :raises HTTPException: If an unexpected error occurs during the retrieval process.