Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1b1cf5f
Add db components from ispyb
stephen-riggs Dec 1, 2025
ce045b6
Merge together all similar tables
stephen-riggs Dec 1, 2025
e966b2a
Register movies on the murfey side
stephen-riggs Dec 2, 2025
7dad07e
Wrong naming
stephen-riggs Dec 2, 2025
4027b55
Split out the dbs
stephen-riggs Jan 7, 2026
3bc60aa
Columns different way around
stephen-riggs Jan 8, 2026
414ecdd
Got mappings wrong
stephen-riggs Jan 8, 2026
9579697
Merge branch 'main' into processing-db
stephen-riggs Jan 8, 2026
d5fe52b
Add setup options for processing tables
stephen-riggs Jan 9, 2026
b4ac97e
Merge branch 'main' into processing-db
stephen-riggs Jan 26, 2026
70ebca9
Test that the processing db can be set up
stephen-riggs Jan 26, 2026
c5cf415
Attempt model config
stephen-riggs Jan 26, 2026
8bcb49f
Try different relation method
stephen-riggs Jan 26, 2026
4d87a97
Back to arb types
stephen-riggs Jan 26, 2026
3e67f3d
Try importing whole db
stephen-riggs Feb 19, 2026
5e2003a
Import and pass
stephen-riggs Feb 19, 2026
ace3aba
Arbitrary types
stephen-riggs Feb 19, 2026
4f118ee
More of the chain
stephen-riggs Feb 19, 2026
1a6ba4b
keep going
stephen-riggs Feb 20, 2026
d6c752b
make table
stephen-riggs Feb 20, 2026
c0c686f
ignore types
stephen-riggs Feb 20, 2026
8ac9fe2
mapping
stephen-riggs Feb 20, 2026
9575c34
table inherit table
stephen-riggs Feb 20, 2026
9e2e595
Refactor for no inheritance
stephen-riggs Feb 20, 2026
7462261
Test imported wrong thing
stephen-riggs Feb 20, 2026
49bb064
foreign keys needed
stephen-riggs Feb 20, 2026
c14bc21
Add relations
stephen-riggs Feb 20, 2026
6913633
Maybe that was wrong
stephen-riggs Feb 20, 2026
2aa9f98
That was daft
stephen-riggs Feb 20, 2026
c56ce1e
That was also daft
stephen-riggs Feb 20, 2026
ee715f5
More foreign keys
stephen-riggs Feb 20, 2026
08e3c9a
Casings and typo
stephen-riggs Feb 20, 2026
b6adae7
Try reverting some of the keys
stephen-riggs Feb 20, 2026
fda1f74
Wrong keys
stephen-riggs Feb 20, 2026
09f4830
Merge branch 'main' into processing-db
stephen-riggs Feb 20, 2026
55388f4
missed bracket layer?
stephen-riggs Feb 20, 2026
7b34098
Try without the metadata bit
stephen-riggs Feb 20, 2026
c3a3e18
No need for mapper registry
stephen-riggs Feb 20, 2026
7fe54e5
combine schema files to avoid missing import errors from sqlalchemy s…
d-j-hatton Feb 26, 2026
462d439
small changes to try and help us move to numpy 2
d-j-hatton Feb 26, 2026
f615d4c
Add ice ring density field
stephen-riggs Feb 26, 2026
44249ae
REmove processing db from cli
stephen-riggs Feb 26, 2026
7ea39a7
Remove processing db
stephen-riggs Feb 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/murfey/cli/create_db.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
import argparse

from murfey.util.db import clear, setup
from murfey.util.processing_db import (
clear as processing_db_clear,
setup as processing_db_setup,
)


def run():
parser = argparse.ArgumentParser(
description="Generate the necessary tables for the Murfey database"
)

parser.add_argument(
"--no-clear",
dest="clear",
default=True,
action="store_false",
help="Do not clear current database tables before creating specified tables",
)
parser.add_argument(
"--include-processing",
dest="processing",
default=True,
action="store_true",
help="Include processing results tables (MotionCorr, CTF, etc)",
)

args = parser.parse_args()

from murfey.server.murfey_db import url

if args.clear:
if args.clear and args.processing:
processing_db_clear(url())
elif args.clear:
clear(url())
setup(url())

if args.processing:
processing_db_setup(url())
else:
setup(url())
12 changes: 12 additions & 0 deletions src/murfey/server/api/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ async def request_spa_preprocessing(
db.add(feedback_params)
movie = Movie(
murfey_id=murfey_ids[0],
data_collection_id=detached_ids[1],
path=proc_file.path,
image_number=proc_file.image_number,
tag=proc_file.tag,
Expand Down Expand Up @@ -730,6 +731,17 @@ async def request_tomography_preprocessing(
0
].eer_fractionation_file

movie = Movie(
murfey_id=murfey_ids[0],
data_collection_id=dcid,
path=proc_file.path,
image_number=proc_file.image_number,
tag=proc_file.tag,
)
db.add(movie)
db.commit()
db.close()

zocalo_message: dict = {
"recipes": [recipe_name],
"parameters": {
Expand Down
1 change: 1 addition & 0 deletions src/murfey/server/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,7 @@ def _flush_tomography_preprocessing(message: dict, _db):
p.parent.mkdir(parents=True)
movie = db.Movie(
murfey_id=murfey_ids[0],
data_collection_id=detached_ids[1],
path=f.file_path,
image_number=f.image_number,
tag=f.tag,
Expand Down
85 changes: 83 additions & 2 deletions src/murfey/util/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@
"""

from datetime import datetime
from typing import List, Optional
from typing import TYPE_CHECKING, List, Optional

import sqlalchemy
from sqlmodel import Field, Relationship, SQLModel, create_engine

if TYPE_CHECKING:
from murfey.util.processing_db import (
CTF,
Comment thread Fixed
MotionCorrection,
Comment thread Fixed
ParticleClassificationGroup,
Comment thread Fixed
ParticlePicker,
Comment thread Fixed
Comment thread Fixed
RelativeIceThickness,
Comment thread Fixed
Comment thread Fixed
TiltImageAlignment,
Comment thread Fixed
Comment thread Fixed
Tomogram,
Comment thread Fixed
Comment thread Fixed
)

"""
GENERAL
"""
mapper_registry = sqlalchemy.orm.registry()


class MurfeyUser(SQLModel, table=True): # type: ignore
Expand Down Expand Up @@ -414,7 +426,7 @@
atlas_pixel_size: Optional[float] = None
atlas: str = ""
sample: Optional[int] = None
session: Optional[Session] = Relationship(back_populates="data_collection_groups")
session: Optional["Session"] = Relationship(back_populates="data_collection_groups")
data_collections: List["DataCollection"] = Relationship(
back_populates="data_collection_group",
sa_relationship_kwargs={"cascade": "delete"},
Expand All @@ -433,6 +445,14 @@
sa_relationship_kwargs={"cascade": "delete"},
)
)
grid_squares: Optional[List["GridSquare"]] = Relationship(
back_populates="data_collection_group",
sa_relationship_kwargs={"cascade": "delete"},
)
search_maps: Optional[List["SearchMap"]] = Relationship(
back_populates="data_collection_group",
sa_relationship_kwargs={"cascade": "delete"},
)


class NotificationParameter(SQLModel, table=True): # type: ignore
Expand Down Expand Up @@ -472,6 +492,15 @@
processing_jobs: List["ProcessingJob"] = Relationship(
back_populates="data_collection", sa_relationship_kwargs={"cascade": "delete"}
)
movies: List["Movie"] = Relationship(
back_populates="data_collection", sa_relationship_kwargs={"cascade": "delete"}
)
motion_correction: Optional[List["MotionCorrection"]] = Relationship(
back_populates="data_collection"
)
tomogram: Optional[List["Tomogram"]] = Relationship(
back_populates="data_collection"
)


class ProcessingJob(SQLModel, table=True): # type: ignore
Expand Down Expand Up @@ -573,6 +602,22 @@
murfey_ids: List["MurfeyLedger"] = Relationship(
back_populates="auto_proc_program", sa_relationship_kwargs={"cascade": "delete"}
)
motion_correction: Optional[List["MotionCorrection"]] = Relationship(
back_populates="data_collection"
)
tomogram: Optional[List["Tomogram"]] = Relationship(
back_populates="auto_proc_program"
)
ctf: Optional[List["CTF"]] = Relationship(back_populates="auto_proc_program")
particle_picker: Optional[List["ParticlePicker"]] = Relationship(
back_populates="auto_proc_program"
)
relative_ice_thickness: Optional[List["RelativeIceThickness"]] = Relationship(
back_populates="auto_proc_program"
)
particle_classification_group: Optional[List["ParticleClassificationGroup"]] = (
Relationship(back_populates="auto_proc_program")
)


class MurfeyLedger(SQLModel, table=True): # type: ignore
Expand Down Expand Up @@ -631,6 +676,17 @@
foil_holes: List["FoilHole"] = Relationship(
back_populates="grid_square", sa_relationship_kwargs={"cascade": "delete"}
)
atlas_id: Optional[int] = Field(foreign_key="datacollectiongroup.id")
scaled_pixel_size: Optional[float] = None
pixel_location_x: Optional[int] = None
pixel_location_y: Optional[int] = None
height: Optional[int] = None
width: Optional[int] = None
angle: Optional[float] = None
quality_indicator: Optional[float] = None
data_collection_group: Optional["DataCollectionGroup"] = Relationship(
back_populates="grid_squares"
)


class FoilHole(SQLModel, table=True): # type: ignore
Expand All @@ -656,6 +712,11 @@
preprocess_stashes: List[PreprocessStash] = Relationship(
back_populates="foil_hole", sa_relationship_kwargs={"cascade": "delete"}
)
scaled_pixel_size: Optional[float] = None
pixel_location_x: Optional[int] = None
pixel_location_y: Optional[int] = None
diameter: Optional[int] = None
quality_indicator: Optional[float] = None


class SearchMap(SQLModel, table=True): # type: ignore
Expand Down Expand Up @@ -688,17 +749,37 @@
tilt_series: List["TiltSeries"] = Relationship(
back_populates="search_map", sa_relationship_kwargs={"cascade": "delete"}
)
atlas_id: Optional[int] = Field(foreign_key="datacollectiongroup.id")
scaled_pixel_size: Optional[float] = None
pixel_location_x: Optional[int] = None
pixel_location_y: Optional[int] = None
scaled_height: Optional[int] = None
scaled_width: Optional[int] = None
angle: Optional[float] = None
quality_indicator: Optional[float] = None
data_collection_group: Optional["DataCollectionGroup"] = Relationship(
back_populates="search_maps"
)
tomogram: Optional[List["Tomogram"]] = Relationship(back_populates="search_map")


class Movie(SQLModel, table=True): # type: ignore
murfey_id: int = Field(primary_key=True, foreign_key="murfeyledger.id")
data_collection_id: Optional[int] = Field(foreign_key="datacollection.id")
foil_hole_id: int = Field(foreign_key="foilhole.id", nullable=True, default=None)
path: str
image_number: int
tag: str
preprocessed: bool = False
murfey_ledger: Optional[MurfeyLedger] = Relationship(back_populates="movies")
data_collection: Optional["DataCollection"] = Relationship(back_populates="movies")
foil_hole: Optional[FoilHole] = Relationship(back_populates="movies")
motion_correction: Optional[List["MotionCorrection"]] = Relationship(
back_populates="movie"
)
tilt_image_alignment: Optional[List["TiltImageAlignment"]] = Relationship(
back_populates="movie"
)


class CtfParameters(SQLModel, table=True): # type: ignore
Expand Down
Loading
Loading