Skip to content
Merged
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
9 changes: 8 additions & 1 deletion src/murfey/instrument_server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@


@router.post("/sessions/{session_id}/multigrid_watcher")
def start_multigrid_watcher(
def setup_multigrid_watcher(

Check warning on line 141 in src/murfey/instrument_server/api.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/instrument_server/api.py#L141

Added line #L141 was not covered by tests
session_id: MurfeySessionID, watcher_spec: MultigridWatcherSpec
):
if controllers.get(session_id) is not None:
Expand Down Expand Up @@ -182,6 +182,13 @@
watchers[session_id].subscribe(
controllers[session_id]._multigrid_watcher_finalised, final=True
)
return {"success": True}

Check warning on line 185 in src/murfey/instrument_server/api.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/instrument_server/api.py#L185

Added line #L185 was not covered by tests


@router.post("/sessions/{session_id}/start_multigrid_watcher")
def start_multigrid_watcher(session_id: MurfeySessionID):

Check warning on line 189 in src/murfey/instrument_server/api.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/instrument_server/api.py#L188-L189

Added lines #L188 - L189 were not covered by tests
if watchers.get(session_id) is None:
return {"success": False}

Check warning on line 191 in src/murfey/instrument_server/api.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/instrument_server/api.py#L191

Added line #L191 was not covered by tests
watchers[session_id].start()
return {"success": True}

Expand Down
23 changes: 22 additions & 1 deletion src/murfey/server/api/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@


@router.post("/sessions/{session_id}/multigrid_watcher")
async def start_multigrid_watcher(
async def setup_multigrid_watcher(
session_id: MurfeySessionID, watcher_spec: MultigridWatcherSetup, db=murfey_db
):
data = {}
Expand Down Expand Up @@ -139,6 +139,27 @@
return data


@router.post("/sessions/{session_id}/start_multigrid_watcher")
async def start_multigrid_watcher(session_id: MurfeySessionID, db=murfey_db):
data = {}
instrument_name = (

Check warning on line 145 in src/murfey/server/api/instrument.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/api/instrument.py#L144-L145

Added lines #L144 - L145 were not covered by tests
db.exec(select(Session).where(Session.id == session_id)).one().instrument_name
)
machine_config = get_machine_config(instrument_name=instrument_name)[

Check warning on line 148 in src/murfey/server/api/instrument.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/api/instrument.py#L148

Added line #L148 was not covered by tests
instrument_name
]
if machine_config.instrument_server_url:
async with aiohttp.ClientSession() as clientsession:
async with clientsession.post(

Check warning on line 153 in src/murfey/server/api/instrument.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/api/instrument.py#L152-L153

Added lines #L152 - L153 were not covered by tests
f"{machine_config.instrument_server_url}/sessions/{session_id}/start_multigrid_watcher",
headers={
"Authorization": f"Bearer {instrument_server_tokens[session_id]['access_token']}"
},
) as resp:
data = await resp.json()
return data

Check warning on line 160 in src/murfey/server/api/instrument.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/api/instrument.py#L159-L160

Added lines #L159 - L160 were not covered by tests


class ProvidedProcessingParameters(BaseModel):
dose_per_frame: float
extract_downscale: bool = True
Expand Down