Skip to content

Commit a59f6fc

Browse files
committed
Merged recent changes from 'bump-mariadb-version'
2 parents 0b5f0ca + 1c6d75e commit a59f6fc

5 files changed

Lines changed: 316 additions & 171 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
python-version: ["3.11", "3.12", "3.13", "3.14"]
1818
services:
1919
mariadb:
20-
image: mariadb:13.0.2 # released 2026-10-09
20+
image: mariadb:12.3 # released 2026-10-17
2121
# Pulls image from DockerHub
2222
# Docker images: https://hub.docker.com/_/mariadb
2323
# Previous version(s):
@@ -88,7 +88,7 @@ jobs:
8888
- uses: shogo82148/actions-setup-mysql@v1
8989
with:
9090
distribution: "mariadb"
91-
mysql-version: "11.3"
91+
mysql-version: "12.3"
9292
auto-start: false
9393

9494
- name: Set up test ISPyB database

‎pyproject.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ developer = [
5454
"pytest-mock", # Additional mocking tools for unit tests
5555
]
5656
server = [
57-
"ccpem-pipeliner",
57+
"ccpem-pipeliner@git+https://gitlab.com/ccpem/ccpem-pipeliner.git@live-processing#egg=ccpem-pipeliner",
5858
"cryptography",
5959
"graypy",
6060
"ispyb>=12.1.0", # Responsible for setting requirements for SQLAlchemy and mysql-connector-python;
@@ -97,6 +97,7 @@ GitHub = "https://github.com/DiamondLightSource/python-murfey"
9797
"murfey.simulate" = "murfey.cli.dummy:run"
9898
"murfey.spa_inject" = "murfey.cli.inject_spa_processing:run"
9999
"murfey.transfer" = "murfey.cli.transfer:run"
100+
"murfey.check_pipeliner_jobs" = "murfey.cli.check_pipeliner_jobs:run"
100101
[project.entry-points."murfey.config.extraction"]
101102
"murfey_machine" = "murfey.util.config:get_extended_machine_config"
102103
[project.entry-points."murfey.contexts"]
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
"""
2+
Validate the job numbering in a CCP-EM Pipeliner project.
3+
4+
SPA live processing allocates Pipeliner job numbers from several processes at
5+
once (Murfey reserving them at schedule time, the node creator registering them
6+
once compute finishes). When that allocation goes wrong then it shows up in
7+
default_pipeline.star as two job types sharing a number, or as a block of
8+
numbers unused, or jobs falling out of order.
9+
"""
10+
11+
from __future__ import annotations
12+
13+
import argparse
14+
import re
15+
import sys
16+
from collections import defaultdict
17+
from pathlib import Path
18+
from typing import Dict, List
19+
20+
from gemmi import cif
21+
from pipeliner.star_keys import (
22+
GENERAL_BLOCK,
23+
JOB_COUNTER,
24+
PROCESS_BLOCK,
25+
PROCESS_PREFIX,
26+
PROCESS_SUFFIXES,
27+
)
28+
29+
JOB_NUMBER = re.compile(r"/job(\d+)/?$")
30+
31+
32+
def _job_number(process_name: str) -> int | None:
33+
match = JOB_NUMBER.search(process_name.rstrip("/") + "/")
34+
return int(match.group(1)) if match else None
35+
36+
37+
def check_project(project_dir: Path) -> List[str]:
38+
"""Return a list of problems found in the project's job numbering."""
39+
pipeline_file = project_dir / "default_pipeline.star"
40+
if not pipeline_file.is_file():
41+
return [f"No default_pipeline.star in {project_dir}"]
42+
43+
doc = cif.read_file(str(pipeline_file))
44+
general = doc.find_block(GENERAL_BLOCK)
45+
if general is None:
46+
return [f"{pipeline_file} has no {GENERAL_BLOCK} block"]
47+
job_counter = int(general.find_value(JOB_COUNTER))
48+
49+
process_block = doc.find_block(PROCESS_BLOCK)
50+
if process_block is None:
51+
return [f"{pipeline_file} has no {PROCESS_BLOCK} block"]
52+
53+
# Process name and type are the first and third columns of the process table.
54+
by_number: Dict[int, List[str]] = defaultdict(list)
55+
unnumbered: List[str] = []
56+
for row in process_block.find(PROCESS_PREFIX, PROCESS_SUFFIXES):
57+
name = cif.as_string(row[0])
58+
job_type = cif.as_string(row[2])
59+
number = _job_number(name)
60+
if number is None:
61+
unnumbered.append(name)
62+
else:
63+
by_number[number].append(f"{name} ({job_type})")
64+
65+
problems: List[str] = []
66+
for name in unnumbered:
67+
problems.append(f"Process {name} has no jobNNN number")
68+
69+
for number in sorted(n for n, procs in by_number.items() if len(procs) > 1):
70+
problems.append(
71+
f"job{number:03} is used by {len(by_number[number])} processes: "
72+
+ ", ".join(sorted(by_number[number]))
73+
)
74+
75+
if by_number:
76+
highest = max(by_number)
77+
gaps = sorted(set(range(1, highest + 1)) - set(by_number))
78+
if gaps:
79+
problems.append(
80+
"Job numbers reserved but never used: "
81+
+ ", ".join(f"job{n:03}" for n in gaps)
82+
)
83+
if job_counter <= highest:
84+
problems.append(
85+
f"{JOB_COUNTER} is {job_counter} but job{highest:03} is already "
86+
"registered — the next job would reuse an existing number"
87+
)
88+
89+
for number, procs in sorted(by_number.items()):
90+
for proc in procs:
91+
job_dir = project_dir / proc.split(" (")[0]
92+
if not job_dir.is_dir():
93+
problems.append(f"Process {proc} has no directory at {job_dir}")
94+
95+
return problems
96+
97+
98+
def run() -> int:
99+
parser = argparse.ArgumentParser(description=__doc__)
100+
parser.add_argument(
101+
"project_dir",
102+
type=Path,
103+
nargs="?",
104+
default=Path.cwd(),
105+
help="Pipeliner project directory (default: the current directory)",
106+
)
107+
args = parser.parse_args()
108+
109+
problems = check_project(args.project_dir)
110+
if not problems:
111+
print(f"{args.project_dir}: job numbering is consistent")
112+
return 0
113+
print(f"{args.project_dir}: {len(problems)} problem(s) found")
114+
for problem in problems:
115+
print(f" - {problem}")
116+
return 1
117+
118+
119+
if __name__ == "__main__":
120+
sys.exit(run())

0 commit comments

Comments
 (0)