File tree Expand file tree Collapse file tree 6 files changed +32
-26
lines changed
Expand file tree Collapse file tree 6 files changed +32
-26
lines changed Original file line number Diff line number Diff line change 1616 MurfeyInstanceEnvironment ,
1717)
1818from murfey .server .api .file_manip import router as file_manip_router
19+ from murfey .server .api .session_control import router as session_router
1920from murfey .server .api .workflow import spa_router as workflow_spa_router
2021from murfey .util .client import (
2122 authorised_requests ,
@@ -264,7 +265,7 @@ def gather_metadata(
264265 binning_factor = 1
265266 if environment :
266267 server_config_response = capture_get (
267- f"{ str (environment .url .geturl ())} /instruments/ { environment .instrument_name } /machine "
268+ f"{ str (environment .url .geturl ())} { session_router . url_path_for ( 'machine_info_by_instrument' , instrument_name = environment .instrument_name ) } "
268269 )
269270 if server_config_response is None :
270271 return None
Original file line number Diff line number Diff line change 1818 MurfeyInstanceEnvironment ,
1919)
2020from murfey .server .api .file_manip import router as file_manip_router
21+ from murfey .server .api .session_control import router as session_router
2122from murfey .server .api .workflow import router as workflow_router
2223from murfey .server .api .workflow import tomo_router as workflow_tomo_router
2324from murfey .util .client import (
@@ -595,7 +596,7 @@ def gather_metadata(
595596 binning_factor = 1
596597 if environment :
597598 server_config = requests .get (
598- f"{ str (environment .url .geturl ())} /instruments/ { environment .instrument_name } /machine "
599+ f"{ str (environment .url .geturl ())} { session_router . url_path_for ( 'machine_info_by_instrument' , instrument_name = environment .instrument_name ) } "
599600 ).json ()
600601 if (
601602 server_config .get ("superres" )
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33import logging
4- import os
5- from functools import lru_cache
64from pathlib import Path
75from typing import Dict , List , Optional
86
2927from murfey .server .api .auth import MurfeySessionID , validate_token
3028from murfey .server .murfey_db import murfey_db
3129from murfey .util import safe_run
32- from murfey .util .config import MachineConfig , from_file , settings
3330from murfey .util .db import (
3431 ClientEnvironment ,
3532 DataCollection ,
@@ -97,26 +94,6 @@ def connections_check():
9794 return {"connections" : list (ws .manager .active_connections .keys ())}
9895
9996
100- @router .get ("/machine" )
101- def machine_info () -> Optional [MachineConfig ]:
102- instrument_name = os .getenv ("BEAMLINE" )
103- if settings .murfey_machine_configuration and instrument_name :
104- return from_file (Path (settings .murfey_machine_configuration ), instrument_name )[
105- instrument_name
106- ]
107- return None
108-
109-
110- @lru_cache (maxsize = 5 )
111- @router .get ("/instruments/{instrument_name}/machine" )
112- def machine_info_by_name (instrument_name : str ) -> Optional [MachineConfig ]:
113- if settings .murfey_machine_configuration :
114- return from_file (Path (settings .murfey_machine_configuration ), instrument_name )[
115- instrument_name
116- ]
117- return None
118-
119-
12097@router .get ("/mag_table/" )
12198def get_mag_table (db = murfey_db ) -> List [MagnificationLookup ]:
12299 return db .exec (select (MagnificationLookup )).all ()
Original file line number Diff line number Diff line change 88import murfey .server .ispyb
99from murfey .server import _transport_object
1010from murfey .server .api .auth import MurfeySessionID , validate_token
11+ from murfey .server .api .shared import get_machine_config_for_instrument
1112from murfey .server .murfey_db import murfey_db
13+ from murfey .util .config import MachineConfig
1214from murfey .util .db import (
1315 AutoProcProgram ,
1416 ClientEnvironment ,
2527)
2628
2729
30+ @router .get ("/instruments/{instrument_name}/machine" )
31+ def machine_info_by_instrument (instrument_name : str ) -> Optional [MachineConfig ]:
32+ return get_machine_config_for_instrument (instrument_name )
33+
34+
2835@router .get ("/new_client_id/" )
2936async def new_client_id (db = murfey_db ):
3037 clients = db .exec (select (ClientEnvironment )).all ()
Original file line number Diff line number Diff line change 1111import murfey .server .ispyb
1212from murfey .server import sanitise , templates
1313from murfey .server .api .auth import MurfeySessionID , validate_token
14+ from murfey .server .api .shared import get_machine_config_for_instrument
1415from murfey .server .murfey_db import murfey_db
15- from murfey .util .config import get_machine_config
16+ from murfey .util .config import MachineConfig , get_machine_config
1617from murfey .util .db import (
1718 ClientEnvironment ,
1819 DataCollection ,
3940)
4041
4142
43+ @router .get ("/instruments/{instrument_name}/machine" )
44+ def machine_info_by_instrument (instrument_name : str ) -> Optional [MachineConfig ]:
45+ return get_machine_config_for_instrument (instrument_name )
46+
47+
4248@router .get ("/instruments/{instrument_name}/visits_raw" , response_model = List [Visit ])
4349def get_current_visits (instrument_name : str , db = murfey .server .ispyb .DB ):
4450 return murfey .server .ispyb .get_all_ongoing_visits (instrument_name , db )
Original file line number Diff line number Diff line change 1+ from functools import lru_cache
2+ from pathlib import Path
3+ from typing import Optional
4+
5+ from murfey .util .config import MachineConfig , from_file , settings
6+
7+
8+ @lru_cache (maxsize = 5 )
9+ def get_machine_config_for_instrument (instrument_name : str ) -> Optional [MachineConfig ]:
10+ if settings .murfey_machine_configuration :
11+ return from_file (Path (settings .murfey_machine_configuration ), instrument_name )[
12+ instrument_name
13+ ]
14+ return None
You can’t perform that action at this time.
0 commit comments