# Path: virtool/analyses/models.py
# class AnalysisFile(Base):
#     """
#     SQL model to store new analysis files
# 
#     """
# 
#     __tablename__ = "analysis_files"
# 
#     id = Column(Integer, primary_key=True)
#     analysis = Column(String)
#     description = Column(String)
#     format = Column(Enum(AnalysisFormat))
#     name = Column(String)
#     name_on_disk = Column(String, unique=True)
#     size = Column(BigInteger)
#     uploaded_at = Column(DateTime)


from pathlib import Path
from typing import Dict
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession
from virtool.analyses.models import AnalysisFile
import virtool.analyses.utils
import virtool.utils




async def create_analysis_file(
    pg: AsyncEngine, analysis_id: str, analysis_format: str, name: str, size: int = None
) -> Dict[str, any]:
    """
    Create a row in the `analysis_files` SQL table that represents an analysis result file.

    :param pg: PostgreSQL AsyncEngine object
    :param analysis_id: ID that corresponds to a parent analysis
    :param analysis_format: Format of the analysis result file
    :param name: Name of the analysis result file
    :param size: Size of the analysis result file
    :return: A dictionary representation of the newly created row
    """
    async with AsyncSession(pg) as session:

# Path: virtool/analyses/models.py
# class AnalysisFile(Base):
#     """
#     SQL model to store new analysis files
# 
#     """
# 
#     __tablename__ = "analysis_files"
# 
#     id = Column(Integer, primary_key=True)
#     analysis = Column(String)
#     description = Column(String)
#     format = Column(Enum(AnalysisFormat))
#     name = Column(String)
#     name_on_disk = Column(String, unique=True)
#     size = Column(BigInteger)
#     uploaded_at = Column(DateTime)


# Path: virtool/analyses/files.py
from pathlib import Path
from typing import Dict
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession
from virtool.analyses.models import AnalysisFile
import virtool.analyses.utils
import virtool.utils





async def create_analysis_file(
    pg: AsyncEngine, analysis_id: str, analysis_format: str, name: str, size: int = None
) -> Dict[str, any]:
    """
    Create a row in the `analysis_files` SQL table that represents an analysis result file.

    :param pg: PostgreSQL AsyncEngine object
    :param analysis_id: ID that corresponds to a parent analysis
    :param analysis_format: Format of the analysis result file
    :param name: Name of the analysis result file
    :param size: Size of the analysis result file
    :return: A dictionary representation of the newly created row
    """
    async with AsyncSession(pg) as session:

        analysis_file = AnalysisFile(