Skip to content

Commit dd39927

Browse files
authored
[LIMS-1700] Make classification values optional (#2)
* Make classification values optional * Update test database * Update workflows * Add extra movie test
1 parent cfaa522 commit dd39927

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

.github/workflows/db-docker-image.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
push:
1111
paths:
1212
- "database/**"
13-
branches: ["master"]
1413

1514
env:
1615
REGISTRY: ghcr.io

database/data.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,7 +2879,7 @@ CREATE TABLE `DataCollection` (
28792879
CONSTRAINT `DataCollection_ibfk_6` FOREIGN KEY (`startPositionId`) REFERENCES `MotorPosition` (`motorPositionId`),
28802880
CONSTRAINT `DataCollection_ibfk_7` FOREIGN KEY (`endPositionId`) REFERENCES `MotorPosition` (`motorPositionId`),
28812881
CONSTRAINT `DataCollection_ibfk_8` FOREIGN KEY (`blSubSampleId`) REFERENCES `BLSubSample` (`blSubSampleId`)
2882-
) ENGINE=InnoDB AUTO_INCREMENT=6017785 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
2882+
) ENGINE=InnoDB AUTO_INCREMENT=6017786 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
28832883
/*!40101 SET character_set_client = @saved_cs_client */;
28842884

28852885
--
@@ -2996,7 +2996,7 @@ CREATE TABLE `DataCollectionGroup` (
29962996
CONSTRAINT `DataCollectionGroup_ibfk_1` FOREIGN KEY (`blSampleId`) REFERENCES `BLSample` (`blSampleId`) ON DELETE CASCADE ON UPDATE CASCADE,
29972997
CONSTRAINT `DataCollectionGroup_ibfk_2` FOREIGN KEY (`sessionId`) REFERENCES `BLSession` (`sessionId`) ON DELETE CASCADE ON UPDATE CASCADE,
29982998
CONSTRAINT `DataCollectionGroup_ibfk_4` FOREIGN KEY (`experimentTypeId`) REFERENCES `ExperimentType` (`experimentTypeId`)
2999-
) ENGINE=InnoDB AUTO_INCREMENT=5441043 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='a dataCollectionGroup is a group of dataCollection for a spe';
2999+
) ENGINE=InnoDB AUTO_INCREMENT=5441044 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='a dataCollectionGroup is a group of dataCollection for a spe';
30003000
/*!40101 SET character_set_client = @saved_cs_client */;
30013001

30023002
--
@@ -5284,7 +5284,7 @@ CREATE TABLE `ProcessingJob` (
52845284
PRIMARY KEY (`processingJobId`),
52855285
KEY `ProcessingJob_ibfk1` (`dataCollectionId`),
52865286
CONSTRAINT `ProcessingJob_ibfk1` FOREIGN KEY (`dataCollectionId`) REFERENCES `DataCollection` (`dataCollectionId`)
5287-
) ENGINE=InnoDB AUTO_INCREMENT=3702 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='From this we get both job times and lag times';
5287+
) ENGINE=InnoDB AUTO_INCREMENT=3711 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='From this we get both job times and lag times';
52885288
/*!40101 SET character_set_client = @saved_cs_client */;
52895289

52905290
--
@@ -5379,7 +5379,7 @@ CREATE TABLE `ProcessingJobParameter` (
53795379
KEY `ProcessingJobParameter_ibfk1` (`processingJobId`),
53805380
KEY `ProcessingJobParameter_idx_paramKey_procJobId` (`parameterKey`,`processingJobId`),
53815381
CONSTRAINT `ProcessingJobParameter_ibfk1` FOREIGN KEY (`processingJobId`) REFERENCES `ProcessingJob` (`processingJobId`)
5382-
) ENGINE=InnoDB AUTO_INCREMENT=24155 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
5382+
) ENGINE=InnoDB AUTO_INCREMENT=24255 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
53835383
/*!40101 SET character_set_client = @saved_cs_client */;
53845384

53855385
--
@@ -8275,4 +8275,4 @@ UNLOCK TABLES;
82758275
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
82768276
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
82778277

8278-
-- Dump completed on 2025-03-20 11:49:05
8278+
-- Dump completed on 2025-04-23 9:38:30

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies = [
2525
"pydantic[email]~=2.9.2",
2626
"fpdf2~=2.8.2",
2727
"types-requests",
28-
"lims-utils~=0.4.1"
28+
"lims-utils~=0.4.3"
2929
]
3030
dynamic = ["version"]
3131
license.file = "LICENSE"

src/pato/crud/movies.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Optional
22

3+
from fastapi import HTTPException, status
34
from lims_utils.tables import CTF, FoilHole, MotionCorrection, Movie, RelativeIceThickness
45
from sqlalchemy import func as f
56
from sqlalchemy import select
@@ -77,8 +78,16 @@ def get_relative_ice_thickness(
7778
return IceThicknessWithAverage(avg=None, current=movie_data)
7879

7980
def get_movie_info(movieId: int) -> MovieData:
80-
return db.session.execute(
81+
movie = db.session.execute(
8182
select(*unravel(Movie), FoilHole.gridSquareId)
8283
.join(FoilHole, FoilHole.foilHoleId==Movie.foilHoleId)
8384
.filter(Movie.movieId == movieId)
8485
).one_or_none()
86+
87+
if movie is None:
88+
raise HTTPException(
89+
status_code=status.HTTP_404_NOT_FOUND,
90+
detail="No items found",
91+
)
92+
93+
return movie

src/pato/models/response.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,10 @@ class Classification(OrmBaseModel):
434434
classNumber: int
435435
classImageFullPath: Optional[str] = None
436436
particlesPerClass: Optional[int] = None
437-
rotationAccuracy: float
438-
translationAccuracy: float
439-
estimatedResolution: float
440-
overallFourierCompleteness: float
437+
rotationAccuracy: Optional[float] = None
438+
translationAccuracy: Optional[float] = None
439+
estimatedResolution: Optional[float] = None
440+
overallFourierCompleteness: Optional[float] = None
441441
classDistribution: Optional[float] = None
442442
selected: Optional[bool] = None
443443
bFactorFitIntercept: Optional[float] = None

tests/movies/test_ids.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ def test_get_movie_info(mock_permissions, client):
55
assert resp.json()["foilHoleId"] == 1
66
assert resp.json()["gridSquareId"] == 1
77

8+
def test_inexistent(mock_permissions, client):
9+
"""Should raise exception if movie not in database"""
10+
resp = client.get("/movies/9999")
11+
assert resp.status_code == 404

0 commit comments

Comments
 (0)