Skip to content

Commit 574b89b

Browse files
committed
Atlas post needs to be a model
1 parent 3914439 commit 574b89b

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/murfey/client/contexts/atlas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ def post_transfer(
4545
) / transferred_file.relative_to(source.parent)
4646
capture_post(
4747
f"{str(environment.url.geturl())}{url_path_for('session_control.spa_router', 'make_atlas_jpg', session_id=environment.murfey_session)}",
48-
json={"atlas_mrc": str(transferred_atlas_name)},
48+
json={"path": str(transferred_atlas_name)},
4949
)

src/murfey/client/multigrid_control.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def _rsyncer_stopped(self, source: Path, explicit_stop: bool = False):
232232
requests.delete(remove_url)
233233
else:
234234
stop_url = f"{self.murfey_url}{url_path_for('session_control.router', 'register_stopped_rsyncer', session_id=self.session_id)}"
235-
capture_post(stop_url, json={"source": str(source)})
235+
capture_post(stop_url, json={"path": str(source)})
236236

237237
def _finalise_rsyncer(self, source: Path):
238238
finalise_thread = threading.Thread(
@@ -248,7 +248,7 @@ def _finalise_rsyncer(self, source: Path):
248248
def _restart_rsyncer(self, source: Path):
249249
self.rsync_processes[source].restart()
250250
restarted_url = f"{self.murfey_url}{url_path_for('session_control.router', 'register_restarted_rsyncer', session_id=self.session_id)}"
251-
capture_post(restarted_url, json={"source": str(source)})
251+
capture_post(restarted_url, json={"path": str(source)})
252252

253253
def _request_watcher_stop(self, source: Path):
254254
self._environment.watchers[source]._stopping = True

src/murfey/server/api/session_control.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,18 +263,18 @@ def get_rsyncers_for_session(session_id: MurfeySessionID, db=murfey_db):
263263
return rsync_instances.all()
264264

265265

266-
class RsyncerSource(BaseModel):
267-
source: str
266+
class StringOfPathModel(BaseModel):
267+
path: str
268268

269269

270270
@router.post("/sessions/{session_id}/rsyncer_stopped")
271271
def register_stopped_rsyncer(
272-
session_id: int, rsyncer_source: RsyncerSource, db=murfey_db
272+
session_id: int, rsyncer_source: StringOfPathModel, db=murfey_db
273273
):
274274
rsyncer = db.exec(
275275
select(RsyncInstance)
276276
.where(RsyncInstance.session_id == session_id)
277-
.where(RsyncInstance.source == rsyncer_source.source)
277+
.where(RsyncInstance.source == rsyncer_source.path)
278278
).one()
279279
rsyncer.transferring = False
280280
db.add(rsyncer)
@@ -283,12 +283,12 @@ def register_stopped_rsyncer(
283283

284284
@router.post("/sessions/{session_id}/rsyncer_started")
285285
def register_restarted_rsyncer(
286-
session_id: int, rsyncer_source: RsyncerSource, db=murfey_db
286+
session_id: int, rsyncer_source: StringOfPathModel, db=murfey_db
287287
):
288288
rsyncer = db.exec(
289289
select(RsyncInstance)
290290
.where(RsyncInstance.session_id == session_id)
291-
.where(RsyncInstance.source == rsyncer_source.source)
291+
.where(RsyncInstance.source == rsyncer_source.path)
292292
).one()
293293
rsyncer.transferring = True
294294
db.add(rsyncer)
@@ -349,9 +349,13 @@ def get_foil_hole(
349349

350350

351351
@spa_router.post("/sessions/{session_id}/make_atlas_jpg")
352-
def make_atlas_jpg(session_id: MurfeySessionID, atlas_mrc: str, db=murfey_db):
352+
def make_atlas_jpg(
353+
session_id: MurfeySessionID, atlas_mrc: StringOfPathModel, db=murfey_db
354+
):
353355
session = db.exec(select(Session).where(Session.id == session_id)).one()
354-
return atlas_jpg_from_mrc(session.instrument_name, session.visit, Path(atlas_mrc))
356+
return atlas_jpg_from_mrc(
357+
session.instrument_name, session.visit, Path(atlas_mrc.path)
358+
)
355359

356360

357361
@spa_router.post("/sessions/{session_id}/grid_square/{gsid}")

0 commit comments

Comments
 (0)