Skip to content

Commit 5a216b6

Browse files
committed
Add option to hide industrial visits from staff
1 parent ada4a36 commit 5a216b6

File tree

18 files changed

+217
-132
lines changed

18 files changed

+217
-132
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# The devcontainer should use the build target and run as root with podman
44
# or docker with user namespaces.
55
#
6-
FROM docker.io/library/python:3.13.2-slim-bullseye as build
6+
FROM docker.io/library/python:3.13.2-slim-bookworm as build
77

88
# Add any system dependencies for the developer/build environment here
99
RUN apt-get update && apt-get upgrade -y && \
@@ -40,7 +40,7 @@ RUN pip install --upgrade pip && \
4040
# and replace with a comment to avoid a zero length asset upload later
4141
sed -i '/file:/s/^/# Requirements for /' lockfiles/requirements.txt
4242

43-
FROM docker.io/library/python:3.13.2-slim-bullseye as runtime
43+
FROM docker.io/library/python:3.13.2-slim-bookworm as runtime
4444

4545
# Add apt-get system dependecies for runtime here if needed
4646
RUN apt-get update && apt-get install -y libmariadb-dev

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ As for the JSON configuration file, details are as follows:
3535
- port: Mesasge queue port
3636
- queue: Queue name
3737
- vhost: Message queue virtual host
38+
- consumer_queue: Queue to consume messages from (for notifications)
3839
- ispyb
3940
- pool: Connection pool size
4041
- overflow: Connection pool overflow max size
@@ -43,6 +44,7 @@ As for the JSON configuration file, details are as follows:
4344
- smtp_server: SMTP server host
4445
- smtp_port: SMTP port to be used for emailing reports
4546
- active_session_cutoff: Time, in weeks, to be used as a threshold for determining if a session is active or not, following the end of the first processing pipeline. For example, a session would be considered inactive if there were no new actions for the past 5 weeks, by default.
47+
- users_only_on_industrial: Hide industrial session details from staff, only display it to users/staff directly listed as part of that visit
4648

4749
==========
4850
Deployment

config.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"host": "127.0.0.1",
3030
"port": 5672,
3131
"queue": "processing_recipe",
32-
"vhost": "/"
32+
"vhost": "/",
33+
"consumer_queue": "pato_notification"
3334
},
3435
"ispyb": { "pool": 3, "overflow": 6 },
3536
"facility": {
@@ -38,7 +39,8 @@
3839
"smtp_server": "smtp.ac.uk",
3940
"active_session_cutoff": 5,
4041
"sample_handling_url": "https://ebic-sample-handling.diamond.ac.uk",
41-
"frontend_url": "http://localhost:8080"
42+
"frontend_url": "http://localhost:8080",
43+
"users_only_on_industrial": false
4244
},
4345
"enable_cors": false
4446
}

database/data.sql

Lines changed: 48 additions & 37 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ description = "PATO's backend"
1616
dependencies = [
1717
"python-multipart~=0.0.9",
1818
"pika~=1.3.2",
19-
"SQLAlchemy~=2.0.34",
20-
"fastapi~=0.115.5",
21-
"uvicorn[standard]~=0.30.1",
19+
"SQLAlchemy~=2.0.40",
20+
"fastapi~=0.115.12",
21+
"uvicorn[standard]~=0.34.2",
2222
"requests~=2.32.3",
23-
"mysqlclient~=2.2.4",
23+
"mysqlclient~=2.2.7",
2424
"mysql-connector-python~=8.2.0",
25-
"pydantic[email]~=2.9.2",
26-
"fpdf2~=2.8.2",
25+
"pydantic[email]~=2.11.3",
26+
"fpdf2~=2.8.3",
2727
"types-requests",
28-
"lims-utils~=0.4.3"
28+
"lims-utils~=0.4.4"
2929
]
3030
dynamic = ["version"]
3131
license.file = "LICENSE"
@@ -100,7 +100,7 @@ allowlist_externals =
100100
# sphinx-build
101101
# sphinx-autobuild
102102
commands =
103-
pytest: pytest tests --cov=pato --cov-report term --cov-report xml:cov.xml {posargs} -s
103+
pytest: pytest tests --cov=pato --cov-report term --cov-report xml:cov.xml {posargs}
104104
mypy: mypy src tests {posargs}
105105
pre-commit: pre-commit run --all-files {posargs}
106106
setenv =

src/pato/auth/micro.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ def __init__(
4242
super().__init__(**user)
4343

4444

45-
def _check_perms(data_id: str | int, endpoint: str, token: str, options: str = ""):
45+
def _check_perms(data_id: str | int, endpoint: str, token: str, options: dict[str, str | int | bool] = {}):
4646
response = requests.get(
4747
"".join(
48-
[Config.auth.endpoint, "permission/", endpoint, "/", str(data_id), options]
48+
[Config.auth.endpoint, "permission/", endpoint, "/", str(data_id)]
4949
),
50+
params={**options, "usersOnly": True},
5051
headers={"Authorization": f"Bearer {token}"},
5152
)
5253

@@ -117,7 +118,7 @@ def data_collection_group(
117118
detail="Data collection group not found",
118119
)
119120

120-
_check_perms(session_id, "session", token.credentials, "?useId=true")
121+
_check_perms(session_id, "session", token.credentials, {"useId": True})
121122

122123
return groupId
123124

@@ -140,7 +141,7 @@ def grid_square(
140141
detail="Grid square not found",
141142
)
142143

143-
_check_perms(session_id, "session", token.credentials, "?useId=true")
144+
_check_perms(session_id, "session", token.credentials, {"useId": True})
144145

145146
return gridSquareId
146147

@@ -164,6 +165,6 @@ def foil_holes(
164165
detail="Foil hole not found",
165166
)
166167

167-
_check_perms(session_id, "session", token.credentials, "?useId=true")
168+
_check_perms(session_id, "session", token.credentials, {"useId": True})
168169

169170
return foilHoleId

src/pato/crud/autoproc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
ItemList,
2828
TomogramResponse,
2929
)
30-
from ..utils.database import db, paginate, unravel
30+
from ..utils.database import db, unravel
3131
from ..utils.generic import validate_path
3232

3333

@@ -57,7 +57,7 @@ def get_motion_correction(limit: int, page: int, autoProcId: int) -> Paged[FullM
5757
.order_by(MotionCorrection.imageNumber)
5858
)
5959

60-
return paginate(query, limit, page)
60+
return db.paginate(query, limit, page)
6161

6262

6363
def get_ctf(autoProcId: int):
@@ -94,7 +94,7 @@ def get_particle_picker(autoProcId: int, filterNull: bool, limit: int, page: int
9494
.order_by(MotionCorrection.imageNumber)
9595
)
9696

97-
return paginate(query, limit, page)
97+
return db.paginate(query, limit, page)
9898

9999

100100
_2d_ordering: dict[str, UnaryExpression] = {
@@ -162,7 +162,7 @@ def get_classification(
162162
if excludeUnselected:
163163
query = query.filter(ParticleClassification.selected != 0)
164164

165-
return paginate(query, limit, page)
165+
return db.paginate(query, limit, page)
166166

167167

168168
@validate_path

src/pato/crud/collections.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
ProcessingJobResponse,
4242
TomogramFullResponse,
4343
)
44-
from ..utils.database import db, paginate
44+
from ..utils.database import db
4545
from ..utils.generic import check_session_active, parse_count
4646
from ..utils.pika import PikaPublisher
4747

@@ -102,7 +102,7 @@ def get_tomograms(
102102
.order_by(ProcessingJob.processingJobId.desc())
103103
)
104104

105-
return paginate(query, limit, page, slow_count=False)
105+
return db.paginate(query, limit, page, slow_count=False)
106106

107107

108108
def get_motion_correction(limit: int, page: int, collectionId: int) -> Paged[FullMovie]:
@@ -115,7 +115,7 @@ def get_motion_correction(limit: int, page: int, collectionId: int) -> Paged[Ful
115115
.group_by(Movie.movieId)
116116
)
117117

118-
return paginate(query, limit, page, slow_count=True)
118+
return db.paginate(query, limit, page, slow_count=True)
119119

120120

121121
def initiate_reprocessing_tomogram(
@@ -310,7 +310,7 @@ def get_processing_jobs(
310310
)
311311
)
312312

313-
return paginate(query, limit, page, slow_count=False)
313+
return db.paginate(query, limit, page, slow_count=False)
314314

315315

316316
def _with_ctf_joins(query: Select, collectionId: int):

src/pato/crud/proposals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from ..models.response import ProposalResponse
88
from ..utils.auth import check_proposal
9-
from ..utils.database import paginate
9+
from ..utils.database import db
1010

1111

1212
def get_proposals(
@@ -31,4 +31,4 @@ def get_proposals(
3131
.order_by(BLSession.startDate.desc())
3232
)
3333

34-
return paginate(check_proposal(query, user), limit, page)
34+
return db.paginate(check_proposal(query, user), limit, page)

src/pato/crud/sessions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ..models.response import SessionAllowsReprocessing, SessionResponse
1515
from ..utils.auth import check_session
1616
from ..utils.config import Config
17-
from ..utils.database import db, paginate, unravel
17+
from ..utils.database import db, unravel
1818
from ..utils.generic import ProposalReference, check_session_active, parse_proposal
1919

2020
HDF5_FILE_SIGNATURE = b"\x89\x48\x44\x46\x0d\x0a\x1a\x0a"
@@ -137,7 +137,7 @@ def get_sessions(
137137
isouter=True,
138138
).group_by(BLSession.visit_number, BLSession.proposalId)
139139

140-
return paginate(query, limit, page)
140+
return db.paginate(query, limit, page)
141141

142142

143143
def get_session(proposalReference: ProposalReference):

0 commit comments

Comments
 (0)