mock get sample info from db
CI / lint (push) Skipped
CI / test (3.12) (push) Skipped
CI / test (3.13) (push) Skipped

This commit is contained in:
David Perl committed 2026-12-03 14:56:18 +01:00
1 parent 042938548d
commit 25a7a50d00
1 file changed
+7 -3
+7 -3
View File
@@ -4,6 +4,7 @@ import importlib.metadata
import os
from contextlib import asynccontextmanager
from aareDB import Sample
import uvicorn
from aarecommon.config.beamline import mx_beamline
from aarecommon.config.logger import get_uvicorn_logging_config, setup_logger
@@ -122,13 +123,16 @@ async def sample_info(sample_id: int, token: str = Depends(oauth2_scheme)) -> Lo
UserRightsException: the user may not work on this sample (403).
"""
data = auth.parse_token(token)
info = await run_in_threadpool(aaredb.get_sample_info, sample_id)
# info = await run_in_threadpool(aaredb.get_sample_info, sample_id)
info = samples.find_sample(sample_id)
if info is None:
raise SampleException(f"Sample {sample_id} is not loaded at this beamline.")
access = auth.check_sample_access(data, sample_id, info.sample.pgroup)
access = auth.check_sample_access(data, sample_id, info.user)
if not access.allowed:
raise UserRightsException(message=access.reason, code=AuthErrorCode.FORBIDDEN)
return info
#HACK FOR TESTING
return LoadedSampleInfo(sample=Sample(id=sample_id, pgroup=info.user, sample_name=info.sample_name, position=info.tell_address().pin, data_collection_parameters=None),puck_name=info.puck_name, puck_pgroup=info.user, tell_position=str(info.tell_address()))
@app.post("/sample/mount")