File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed
Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -162,3 +162,8 @@ def set_path_provider(provider: PathProvider):
162162
163163def get_path_provider () -> PathProvider :
164164 return PATH_PROVIDER
165+
166+
167+ def clear_path_provider () -> None :
168+ global PATH_PROVIDER
169+ del PATH_PROVIDER
Original file line number Diff line number Diff line change @@ -33,14 +33,23 @@ def attach_data_session_metadata_wrapper(
3333 Yields:
3434 Iterator[Msg]: Plan messages
3535 """
36- provider = provider or get_path_provider ()
36+ try :
37+ provider = provider or get_path_provider ()
38+ except NameError :
39+ provider = None
40+
3741 if isinstance (provider , UpdatingPathProvider ):
3842 yield from bps .wait_for ([provider .update ])
3943 ress = yield from bps .wait_for ([provider .data_session ])
4044 data_session = ress [0 ].result ()
4145 # https://github.com/DiamondLightSource/dodal/issues/452
4246 # As part of 452, write each dataCollection into their own folder, then can use resource_dir directly
4347 yield from bpp .inject_md_wrapper (plan , md = {DATA_SESSION : data_session })
48+ elif provider is None :
49+ logging .warning (
50+ f"There is no PathProvider set, { attach_data_session_metadata_wrapper .__name__ } will have no effect"
51+ )
52+ yield from plan
4453 else :
4554 logging .warning (
4655 f"{ provider } is not an UpdatingPathProvider, { attach_data_session_metadata_wrapper .__name__ } will have no effect"
Original file line number Diff line number Diff line change 33from bluesky .run_engine import RunEngine
44from bluesky .utils import MsgGenerator
55
6+ from dodal .common .beamlines .beamline_utils import clear_path_provider
67from dodal .plan_stubs .data_session import attach_data_session_metadata_wrapper
78
89
@@ -20,3 +21,16 @@ def fake_plan() -> MsgGenerator[None]:
2021 f"{ path_provider } is not an UpdatingPathProvider, { attach_data_session_metadata_wrapper .__name__ } will have no effect"
2122 in caplog .text
2223 )
24+
25+
26+ def test_attach_data_session_metadata_wrapper_with_no_provider_is_noop (
27+ caplog , RE : RunEngine
28+ ):
29+ def fake_plan () -> MsgGenerator [None ]:
30+ yield from []
31+
32+ clear_path_provider ()
33+ plan = attach_data_session_metadata_wrapper (plan = fake_plan ())
34+ RE (plan )
35+
36+ assert f"There is no PathProvider set, { attach_data_session_metadata_wrapper .__name__ } will have no effect"
You can’t perform that action at this time.
0 commit comments