Skip to content

Commit

Permalink
Changes needed to make the old gui work with the recent updates (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-riggs authored Oct 14, 2024
1 parent ec4286f commit df1497d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/murfey/client/contexts/clem.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def _file_transferred_to(
Returns the Path of the transferred file on the DLS file system.
"""
machine_config = get_machine_config(
str(environment.url.geturl()), demo=environment.demo
str(environment.url.geturl()),
instrument_name=environment.instrument_name,
demo=environment.demo,
)
# rsync basepath and modules are set in the microscope's configuration YAML file
return (
Expand Down
4 changes: 3 additions & 1 deletion src/murfey/client/contexts/spa_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def _atlas_destination(
environment: MurfeyInstanceEnvironment, source: Path, file_path: Path
) -> Path:
machine_config = get_machine_config(
str(environment.url.geturl()), demo=environment.demo
str(environment.url.geturl()),
instrument_name=environment.instrument_name,
demo=environment.demo,
)
if environment.visit in environment.default_destinations[source]:
return (
Expand Down
15 changes: 11 additions & 4 deletions src/murfey/client/tui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def _launch_multigrid_watcher(
):
log.info(f"Launching multigrid watcher for source {source}")
machine_config = get_machine_config(
str(self._environment.url.geturl()), demo=self._environment.demo
str(self._environment.url.geturl()),
instrument_name=self._environment.instrument_name,
demo=self._environment.demo,
)
self._multigrid_watcher = MultigridDirWatcher(
source,
Expand All @@ -154,6 +156,7 @@ def _start_rsyncer_multigrid(
remove_files: bool = False,
analyse: bool = True,
limited: bool = False,
**kwargs,
):
log.info(f"starting multigrid rsyncer: {source}")
destination_overrides = destination_overrides or {}
Expand Down Expand Up @@ -257,7 +260,7 @@ def rsync_result(update: RSyncerUpdate):
),
secondary=True,
)
url = f"{str(self._url.geturl())}/visits/{str(self._visit)}/rsyncer"
url = f"{str(self._url.geturl())}/sessions/{str(self._environment.murfey_session)}/rsyncer"
rsyncer_data = {
"source": str(source),
"destination": destination,
Expand Down Expand Up @@ -686,7 +689,9 @@ def on_log_book_log(self, message):

async def reset(self):
machine_config = get_machine_config(
str(self._environment.url.geturl()), demo=self._environment.demo
str(self._environment.url.geturl()),
instrument_name=self._environment.instrument_name,
demo=self._environment.demo,
)
if self.rsync_processes and machine_config.get("allow_removal"):
sources = "\n".join(str(k) for k in self.rsync_processes.keys())
Expand Down Expand Up @@ -739,7 +744,9 @@ def clean_up_quit(self) -> None:

async def action_clear(self) -> None:
machine_config = get_machine_config(
str(self._environment.url.geturl()), demo=self._environment.demo
str(self._environment.url.geturl()),
instrument_name=self._environment.instrument_name,
demo=self._environment.demo,
)
if self.rsync_processes and machine_config.get("allow_removal"):
sources = "\n".join(str(k) for k in self.rsync_processes.keys())
Expand Down
11 changes: 9 additions & 2 deletions src/murfey/server/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,16 @@ def register_client_to_visit(visit_name: str, client_info: ClientInfo, db=murfey
client_env = db.exec(
select(ClientEnvironment).where(ClientEnvironment.client_id == client_info.id)
).one()
session = db.exec(select(Session).where(Session.id == client_env.session_id)).one()
if client_env:
client_env.visit = visit_name
db.add(client_env)
db.commit()
db.close()
if session:
session.visit = visit_name
db.add(session)
db.commit()
db.close()
return client_info


Expand Down Expand Up @@ -1127,7 +1132,9 @@ async def request_spa_preprocessing(
"particle_diameter": proc_params["particle_diameter"] or 0,
"fm_int_file": proc_file.eer_fractionation_file,
"do_icebreaker_jobs": default_spa_parameters.do_icebreaker_jobs,
"cryolo_model_weights": str(_cryolo_model_path(visit_name)),
"cryolo_model_weights": str(
_cryolo_model_path(visit_name, instrument_name)
),
},
}
# log.info(f"Sending Zocalo message {zocalo_message}")
Expand Down
7 changes: 6 additions & 1 deletion src/murfey/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ def capture_post(url: str, json: dict | list = {}) -> requests.Response | None:
f"{response.status_code}. The reason given was {response.reason}"
)
split_url = urlparse(url)
failure_url = urlunparse(split_url._replace(path="/failed_client_post"))
client_config = read_config()
failure_url = urlunparse(
split_url._replace(
path=f"/instruments/{client_config['Murfey']['instrument_name']}/failed_client_post"
)
)
try:
resend_response = requests.post(
failure_url, json={"url": url, "data": json}
Expand Down
2 changes: 1 addition & 1 deletion tests/client/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_tomography_context_initialisation_for_serialem(tmp_path):
def test_setting_tilt_series_size_and_completion_from_mdoc_parsing(
mock_post, mock_get, tmp_path
):
mock_post.post().status_code = 200
mock_post().status_code = 200

env = MurfeyInstanceEnvironment(
url=urlparse("http://localhost:8000"),
Expand Down

0 comments on commit df1497d

Please sign in to comment.