Skip to content

Commit

Permalink
Speed and reliability fixes in services
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-riggs committed Oct 19, 2023
1 parent 46aee96 commit e311558
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/relion/zocalo/class2d_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def run(self):
)

# Run Class2D and confirm it ran successfully
self.log.info(" ".join(class2d_command))
result = subprocess.run(
class2d_command, cwd=str(project_dir), capture_output=True
)
Expand Down
3 changes: 2 additions & 1 deletion src/relion/zocalo/class3d_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Class3DParameters(BaseModel):
skip_align: bool = False
healpix_order: float = 2
offset_range: float = 5
offset_step: float = 2
offset_step: float = 4
allow_coarser: bool = False
symmetry: str = "C1"
do_norm: bool = True
Expand Down Expand Up @@ -393,6 +393,7 @@ def run(self):
)

# Run Class3D and confirm it ran successfully
self.log.info(" ".join(class3d_command))
result = subprocess.run(
class3d_command, cwd=str(project_dir), capture_output=True
)
Expand Down
25 changes: 12 additions & 13 deletions src/relion/zocalo/images_service_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ def picked_particles(plugin_params):
logger.info(f"Replacing jpeg extension with mrc extension for {basefilename}")
basefilename = basefilename.replace(".jpeg", ".mrc")
coords = plugin_params.parameters("coordinates")
if not coords:
logger.warning(f"No coordinates provided for {basefilename}")
# If there were no coordinates don't bother nacking the message
return True
angpix = plugin_params.parameters("angpix")
diam = plugin_params.parameters("diameter")
contrast_factor = plugin_params.parameters("contrast_factor", default=6)
Expand Down Expand Up @@ -139,15 +135,18 @@ def picked_particles(plugin_params):
enhanced = enhancer.enhance(contrast_factor)
fim = enhanced.filter(ImageFilter.BLUR)
dim = ImageDraw.Draw(fim)
for x, y in coords:
dim.ellipse(
[
(float(x) - radius, float(y) - radius),
(float(x) + radius, float(y) + radius),
],
width=8,
outline="#f58a07",
)
if coords and coords[0]:
for x, y in coords:
dim.ellipse(
[
(float(x) - radius, float(y) - radius),
(float(x) + radius, float(y) + radius),
],
width=8,
outline="#f58a07",
)
else:
logger.warning(f"No coordinates provided for {basefilename}")
try:
fim.save(outfile)
except FileNotFoundError:
Expand Down
16 changes: 16 additions & 0 deletions src/relion/zocalo/motioncorr_wilson.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,22 @@ def motioncor2(self, command: list, mrc_out: Path):
stderr=slurm_status_json.stderr,
)

if loop_counter >= 60:
slurm_cancel_command = (
f'curl -H "X-SLURM-USER-NAME:{user}" '
f'-H "X-SLURM-USER-TOKEN:{slurm_token}" '
'-H "Content-Type: application/json" -X DELETE '
f'{slurm_rest["url"]}/slurm/{slurm_rest["api_version"]}/job/{job_id}'
)
subprocess.run(slurm_cancel_command, capture_output=True, shell=True)
self.log.error("Timeout running motion correction")
return subprocess.CompletedProcess(
args="",
returncode=1,
stdout="".encode("utf8"),
stderr="Timeout running motion correction".encode("utf8"),
)

# Read in the MotionCor output then clean up the files
self.log.info(f"Job {job_id} has finished!")
try:
Expand Down

0 comments on commit e311558

Please sign in to comment.