Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/murfey/cli/inject_spa_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from murfey.util.config import get_machine_config, get_microscope, get_security_config
from murfey.util.db import (
AutoProcProgram,
ClassificationFeedbackParameters,
ClientEnvironment,
DataCollection,
DataCollectionGroup,
Expand Down Expand Up @@ -136,15 +135,11 @@ def run():
.where(AutoProcProgram.pj_id == ProcessingJob.id)
.where(ProcessingJob.recipe == "em-spa-preprocess")
).one()
params = murfey_db.exec(
select(SPARelionParameters, ClassificationFeedbackParameters)
.where(SPARelionParameters.pj_id == collected_ids[2].id)
.where(ClassificationFeedbackParameters.pj_id == SPARelionParameters.pj_id)
proc_params = murfey_db.exec(
select(SPARelionParameters).where(
SPARelionParameters.pj_id == collected_ids[2].id
)
).one()
proc_params: dict | None = dict(params[0])
feedback_params = params[1]
if feedback_params.picker_murfey_id is None:
raise ValueError("No ISPyB picker ID was found")
except sqlalchemy.exc.NoResultFound:
proc_params = None

Expand Down Expand Up @@ -196,7 +191,6 @@ def run():
"ft_bin": proc_params["motion_corr_binning"],
"fm_dose": proc_params["dose_per_frame"],
"gain_ref": proc_params["gain_ref"],
"picker_uuid": feedback_params.picker_murfey_id,
"session_id": args.session_id,
"particle_diameter": proc_params["particle_diameter"] or 0,
"fm_int_file": args.eer_fractionation_file,
Expand Down
5 changes: 5 additions & 0 deletions src/murfey/server/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ async def submit_to_auth_endpoint(
Helper function to forward incoming requests to an authentication server
to verify that they are allowed to inspect the
"""
if security_config.auth_type == "none":
return {"valid": True}

# Forward only essentials auth-related headers
headers = {
Expand Down Expand Up @@ -189,6 +191,9 @@ async def validate_instrument_token(
"""
Used by the backend routers to check the incoming instrument server token.
"""
if security_config.instrument_auth_type == "none":
return None

try:
# Validate using auth URL if provided
if security_config.instrument_auth_url:
Expand Down
54 changes: 30 additions & 24 deletions src/murfey/server/api/session_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def all_visit_info(


@router.get("/sessions/{session_id}/rsyncers", response_model=List[RsyncInstance])
def get_rsyncers_for_client(session_id: MurfeySessionID, db=murfey_db):
def get_rsyncers_for_client(session_id: MurfeySessionID, db: Session = murfey_db):
rsync_instances = db.exec(
select(RsyncInstance).where(RsyncInstance.session_id == session_id)
)
Expand All @@ -142,7 +142,9 @@ class SessionClients(BaseModel):


@router.get("/sessions/{session_id}")
async def get_session(session_id: MurfeySessionID, db=murfey_db) -> SessionClients:
async def get_session(
session_id: MurfeySessionID, db: Session = murfey_db
) -> SessionClients:
session = db.exec(select(Session).where(Session.id == session_id)).one()
clients = db.exec(
select(ClientEnvironment).where(ClientEnvironment.session_id == session_id)
Expand All @@ -151,7 +153,7 @@ async def get_session(session_id: MurfeySessionID, db=murfey_db) -> SessionClien


@router.get("/sessions")
async def get_sessions(db=murfey_db):
async def get_sessions(db: Session = murfey_db):
sessions = db.exec(select(Session)).all()
clients = db.exec(select(ClientEnvironment)).all()
res = []
Expand All @@ -174,7 +176,7 @@ def create_session(
visit: str,
name: str,
visit_end_time: VisitEndTime,
db=murfey_db,
db: Session = murfey_db,
) -> int:
s = Session(
name=name,
Expand All @@ -190,7 +192,7 @@ def create_session(

@router.post("/sessions/{session_id}")
def update_session(
session_id: MurfeySessionID, process: bool = True, db=murfey_db
session_id: MurfeySessionID, process: bool = True, db: Session = murfey_db
) -> None:
session = db.exec(select(Session).where(Session.id == session_id)).one()
session.process = process
Expand All @@ -200,13 +202,13 @@ def update_session(


@router.delete("/sessions/{session_id}")
def remove_session(session_id: MurfeySessionID, db=murfey_db):
def remove_session(session_id: MurfeySessionID, db: Session = murfey_db):
remove_session_by_id(session_id, db)


@router.get("/instruments/{instrument_name}/visits/{visit_name}/sessions")
def get_sessions_with_visit(
instrument_name: MurfeyInstrumentName, visit_name: str, db=murfey_db
instrument_name: MurfeyInstrumentName, visit_name: str, db: Session = murfey_db
) -> List[Session]:
sessions = db.exec(
select(Session)
Expand All @@ -218,7 +220,7 @@ def get_sessions_with_visit(

@router.get("/instruments/{instrument_name}/sessions")
async def get_sessions_by_instrument_name(
instrument_name: MurfeyInstrumentName, db=murfey_db
instrument_name: MurfeyInstrumentName, db: Session = murfey_db
) -> List[Session]:
sessions = db.exec(
select(Session).where(Session.instrument_name == instrument_name)
Expand All @@ -228,7 +230,7 @@ async def get_sessions_by_instrument_name(

@router.get("/sessions/{session_id}/data_collection_groups")
def get_dc_groups(
session_id: MurfeySessionID, db=murfey_db
session_id: MurfeySessionID, db: Session = murfey_db
) -> Dict[str, DataCollectionGroup]:
data_collection_groups = db.exec(
select(DataCollectionGroup).where(DataCollectionGroup.session_id == session_id)
Expand All @@ -238,7 +240,7 @@ def get_dc_groups(

@router.get("/sessions/{session_id}/data_collection_groups/{dcgid}/data_collections")
def get_data_collections(
session_id: MurfeySessionID, dcgid: int, db=murfey_db
session_id: MurfeySessionID, dcgid: int, db: Session = murfey_db
) -> List[DataCollection]:
data_collections = db.exec(
select(DataCollection).where(DataCollection.dcg_id == dcgid)
Expand All @@ -247,7 +249,7 @@ def get_data_collections(


@router.get("/clients")
async def get_clients(db=murfey_db):
async def get_clients(db: Session = murfey_db):
clients = db.exec(select(ClientEnvironment)).all()
return clients

Expand All @@ -258,7 +260,7 @@ class CurrentGainRef(BaseModel):

@router.put("/sessions/{session_id}/current_gain_ref")
def update_current_gain_ref(
session_id: MurfeySessionID, new_gain_ref: CurrentGainRef, db=murfey_db
session_id: MurfeySessionID, new_gain_ref: CurrentGainRef, db: Session = murfey_db
):
session = db.exec(select(Session).where(Session.id == session_id)).one()
session.current_gain_ref = new_gain_ref.path
Expand Down Expand Up @@ -293,7 +295,7 @@ class ProcessingDetails(BaseModel):

@spa_router.get("/sessions/{session_id}/spa_processing_parameters")
def get_spa_proc_param_details(
session_id: MurfeySessionID, db=murfey_db
session_id: MurfeySessionID, db: Session = murfey_db
) -> Optional[List[ProcessingDetails]]:
params = db.exec(
select(
Expand Down Expand Up @@ -342,7 +344,7 @@ def _parse(ps, i, dcg_id):
"/sessions/{session_id}/data_collection_groups/{dcgid}/grid_squares/{gsid}/foil_holes/{fhid}/num_movies"
)
def get_number_of_movies_from_foil_hole(
session_id: int, dcgid: int, gsid: int, fhid: int, db=murfey_db
session_id: int, dcgid: int, gsid: int, fhid: int, db: Session = murfey_db
) -> int:
movies = db.exec(
select(Movie, FoilHole, GridSquare, DataCollectionGroup)
Expand All @@ -358,13 +360,13 @@ def get_number_of_movies_from_foil_hole(


@spa_router.get("/sessions/{session_id}/grid_squares")
def get_grid_squares(session_id: MurfeySessionID, db=murfey_db):
def get_grid_squares(session_id: MurfeySessionID, db: Session = murfey_db):
return _get_grid_squares(session_id, db)


@spa_router.get("/sessions/{session_id}/data_collection_groups/{dcgid}/grid_squares")
def get_grid_squares_from_dcg(
session_id: MurfeySessionID, dcgid: int, db=murfey_db
session_id: MurfeySessionID, dcgid: int, db: Session = murfey_db
) -> List[GridSquare]:
return _get_grid_squares_from_dcg(session_id, dcgid, db)

Expand All @@ -373,14 +375,14 @@ def get_grid_squares_from_dcg(
"/sessions/{session_id}/data_collection_groups/{dcgid}/grid_squares/{gsid}/foil_holes"
)
def get_foil_holes_from_grid_square(
session_id: MurfeySessionID, dcgid: int, gsid: int, db=murfey_db
session_id: MurfeySessionID, dcgid: int, gsid: int, db: Session = murfey_db
) -> List[FoilHole]:
return _get_foil_holes_from_grid_square(session_id, dcgid, gsid, db)


@spa_router.get("/sessions/{session_id}/foil_hole/{fh_name}")
def get_foil_hole(
session_id: MurfeySessionID, fh_name: int, db=murfey_db
session_id: MurfeySessionID, fh_name: int, db: Session = murfey_db
) -> Dict[str, int]:
return _get_foil_hole(session_id, fh_name, db)

Expand All @@ -394,7 +396,7 @@ def get_foil_hole(

@tomo_router.get("/sessions/{session_id}/tilt_series/{tilt_series_tag}/tilts")
def get_tilts(
session_id: MurfeySessionID, tilt_series_tag: str, db=murfey_db
session_id: MurfeySessionID, tilt_series_tag: str, db: Session = murfey_db
) -> Dict[str, List[str]]:
res = db.exec(
select(TiltSeries, Tilt)
Expand All @@ -419,7 +421,7 @@ def get_tilts(


@correlative_router.get("/sessions/{session_id}/upstream_visits")
async def find_upstream_visits(session_id: MurfeySessionID, db=murfey_db):
async def find_upstream_visits(session_id: MurfeySessionID, db: Session = murfey_db):
return _find_upstream_visits(session_id=session_id, db=db)


Expand All @@ -430,7 +432,7 @@ async def gather_upstream_files(
visit_name: str,
session_id: MurfeySessionID,
upstream_file_request: UpstreamFileRequestInfo,
db=murfey_db,
db: Session = murfey_db,
):
return _gather_upstream_files(
session_id=session_id,
Expand All @@ -447,7 +449,7 @@ async def get_upstream_file(
visit_name: str,
session_id: MurfeySessionID,
upstream_file_path: Path,
db=murfey_db,
db: Session = murfey_db,
):
upstream_file = _get_upstream_file(upstream_file_path)
return (
Expand All @@ -458,14 +460,18 @@ async def get_upstream_file(
@correlative_router.get(
"/visits/{visit_name}/sessions/{session_id}/upstream_tiff_paths"
)
async def gather_upstream_tiffs(visit_name: str, session_id: int, db=murfey_db):
async def gather_upstream_tiffs(
visit_name: str, session_id: int, db: Session = murfey_db
):
return _gather_upstream_tiffs(visit_name=visit_name, session_id=session_id, db=db)


@correlative_router.get(
"/visits/{visit_name}/sessions/{session_id}/upstream_tiff/{tiff_path:path}"
)
async def get_tiff_file(visit_name: str, session_id: int, tiff_path: str, db=murfey_db):
async def get_tiff_file(
visit_name: str, session_id: int, tiff_path: str, db: Session = murfey_db
):
tiff_file = _get_tiff_file(
visit_name=visit_name, session_id=session_id, tiff_path=tiff_path, db=db
)
Expand Down
Loading
Loading