flip_api.file_services.download_file

Attributes

router

Functions

download_file(, user_id)

Get a pre-signed download URL for a 'model file' (file uploaded by a user to train/evaluate a model).

Module Contents

flip_api.file_services.download_file.router
flip_api.file_services.download_file.download_file(model_id: uuid.UUID, file_name: flip_api.domain.schemas.file.SafeFileName, db: sqlmodel.Session = Depends(get_session), user_id: uuid.UUID = Depends(verify_token)) flip_api.domain.schemas.file.PresignedDownloadResponse

Get a pre-signed download URL for a ‘model file’ (file uploaded by a user to train/evaluate a model).

The file bytes are never proxied through flip-api: the caller fetches them directly from the returned S3 URL. This keeps large model-file downloads off a client-side request timeout (FLIP#784) and off the Fargate task’s egress bandwidth.

Important: Do not confuse with the ‘retrieve_federated_results’ endpoint which is for downloading ‘model results’ generated as a result of a training/evaluation job and are stored in a different S3 bucket. While ‘viewer’ users can download ‘model results’ using the ‘retrieve_federated_results’ endpoint, only users with ‘modify’ access to a model can download ‘model files’ using this ‘download_file’ endpoint.

Parameters:
  • model_id (UUID) – The ID of the model to retrieve the file for.

  • file_name (str) – The name of the file to download.

  • db (Session) – Database session.

  • user_id (UUID) – User ID from authentication.

Returns:

A short-lived pre-signed S3 GET URL plus the file name.

Return type:

PresignedDownloadResponse

Raises:

HTTPException – If the user is not allowed, if the file does not exist, or there is an error generating the pre-signed URL.