diff --git a/src/geneweaver/api/schemas/batch.py b/src/geneweaver/api/schemas/batch.py index 7a354a9..ec5fa31 100644 --- a/src/geneweaver/api/schemas/batch.py +++ b/src/geneweaver/api/schemas/batch.py @@ -1,11 +1,8 @@ """Module for defining schemas for batch endpoints.""" -from typing import List, Optional - -from pydantic import BaseModel, validator -from geneweaver.core.parse.score import parse_score +from typing import List from geneweaver.api.schemas.messages import MessageResponse -from geneweaver.api.schemas.score import GenesetScoreType +from pydantic import BaseModel class BatchResponse(BaseModel): @@ -13,53 +10,3 @@ class BatchResponse(BaseModel): genesets: List[int] messages: MessageResponse - - -class Publication(BaseModel): - authors: str - title: str - abstract: str - journal: str - volume: str - pages: str - month: str - year: str - pubmed: str - - -class GenesetValueInput(BaseModel): - symbol: str - value: float - - -class GenesetValue(BaseModel): - ode_gene_id: str - value: float - ode_ref_id: str - threshold: bool - - -class BatchUploadGeneset(BaseModel): - score: GenesetScoreType - # TODO: Use enum from core - species: str - gene_id_type: str - pubmed_id: str - private: bool = True - curation_id: Optional[int] = None - abbreviation: str - name: str - description: str - values: List[GenesetValueInput] - - @validator("score", pre=True) - def initialize_score(cls, v): - return parse_score(v) - - @validator("private", pre=True) - def private_to_bool(cls, v): - return v.lower() != "public" - - @validator("curation_id", pre=True) - def curation_id_to_int(cls, v, values): - return 5 if values["private"] else 4 diff --git a/src/geneweaver/api/services/parse/batch.py b/src/geneweaver/api/services/parse/batch.py index ad38b3d..0a75172 100644 --- a/src/geneweaver/api/services/parse/batch.py +++ b/src/geneweaver/api/services/parse/batch.py @@ -1,13 +1,17 @@ +"""Functions for processing batch files. + +Most of the functionality for processing batch files is contained in the +geneweaver.core module. This module contains functions for reading the contents +of a file and passing those contents to the core module for processing. +""" from typing import List, Tuple -from fastapi import UploadFile +from fastapi import UploadFile +from geneweaver.api.services.io import read_file_contents from geneweaver.core.parse import batch from geneweaver.core.schema.messages import SystemMessage, UserMessage -from geneweaver.api.services.io import read_file_contents - - async def process_batch_file( # TODO: Add the database session to the function signature. # db: Session, @@ -38,10 +42,6 @@ async def process_batch_file( print(geneset, "\n") # TODO: Add the genesets to the database - # results = [ - # batch_geneset_for_user(db, user_id, geneset) - # for geneset in genesets - # ] # TODO: Return the correct values. return [10], [], [] diff --git a/tests/services/parse/batch/conftest.py b/tests/services/parse/batch/conftest.py index 4234ad0..aba8611 100644 --- a/tests/services/parse/batch/conftest.py +++ b/tests/services/parse/batch/conftest.py @@ -1,14 +1,16 @@ +"""Pytest fixtures for the batch parsing service tests.""" from unittest.mock import AsyncMock import pytest from fastapi import UploadFile -from tests.api.unit.services.parse.batch import const +from tests.services.parse.batch import const # Create a pytest fixture for the mocked UploadFile @pytest.fixture() def mock_upload_file(): + """Provide a mocked UploadFile object.""" mock_file = AsyncMock(spec=UploadFile) return mock_file # provide the mock object to the test @@ -23,4 +25,5 @@ def mock_upload_file(): ] ) def example_batch_file_contents(request) -> str: + """Provide the contents of the example batch file.""" return request.param diff --git a/tests/services/parse/batch/const.py b/tests/services/parse/batch/const.py index 54684a0..0e5319d 100644 --- a/tests/services/parse/batch/const.py +++ b/tests/services/parse/batch/const.py @@ -1,3 +1,4 @@ +"""Constants for batch parsing tests.""" # ruff: noqa: E501 EXAMPLE_BATCH_FILE = """ # This is an example batch upload file for GeneWeaver. diff --git a/tests/services/parse/batch/test_parse.py b/tests/services/parse/batch/test_parse.py index e69de29..b5f61fd 100644 --- a/tests/services/parse/batch/test_parse.py +++ b/tests/services/parse/batch/test_parse.py @@ -0,0 +1 @@ +"""Test for the parsing service."""