Skip to content

Commit

Permalink
Function in ispyb service for processed tomo insert
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-riggs committed Aug 21, 2024
1 parent ceac3ff commit 898dff2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/cryoemservices/services/denoise_slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ def dummy(self, *args, **kwargs):
"ispyb_command": "buffer",
"buffer_command": {"ispyb_command": "insert_processed_tomogram"},
"buffer_lookup": {"tomogram_id": denoise_params.tomogram_uuid},
"filePath": str(denoised_full_path),
"processingType": "Denoised",
"file_path": str(denoised_full_path),
"processing_type": "Denoised",
}
if isinstance(rw, MockRW):
rw.transport.send(
Expand Down
33 changes: 30 additions & 3 deletions src/cryoemservices/services/ispyb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from collections import ChainMap
from datetime import datetime
from pathlib import Path
from typing import Optional

import ispyb
import ispyb.sqlalchemy as models
Expand Down Expand Up @@ -32,9 +33,9 @@ def __getitem__(self, k):

class MovieParams(BaseModel):
dcid: int
movie_number: int = None # image number
movie_path: str = None # micrograph full path
timestamp: float = None
movie_number: int # image number
movie_path: str # micrograph full path
timestamp: Optional[float] = None


def lookup_command(command, refclass):
Expand Down Expand Up @@ -995,6 +996,32 @@ def full_parameters(param):
)
return False

def do_insert_processed_tomogram(self, parameters, session, message=None, **kwargs):
if message is None:
message = {}
dcid = parameters("dcid")
self.log.info(f"Inserting Processed Tomogram parameters. DCID: {dcid}")

def full_parameters(param):
return message.get(param) or parameters(param)

try:
values = models.ProcessedTomogram(
tomogramId=full_parameters("tomogram_id"),
filePath=full_parameters("file_path"),
processingType=full_parameters("processing_type"),
)
session.add(values)
session.commit()
return {"success": True, "return_value": values.processedTomogramId}
except sqlalchemy.exc.SQLAlchemyError as e:
self.log.error(
"Inserting Processed Tomogram entry caused exception '%s'.",
e,
exc_info=True,
)
return False

def do_insert_tilt_image_alignment(
self, parameters, session, message=None, **kwargs
):
Expand Down

0 comments on commit 898dff2

Please sign in to comment.