Skip to content

Commit

Permalink
Remove current collection on exception
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Mar 4, 2024
1 parent 034a00b commit a85331c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/blueapi/data_management/visit_directory_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ async def update(self) -> None:
# TODO: Query visit service to get information about visit and data collection
# TODO: Use AuthN information as part of verification with visit service

collection_id_info = await self._client.create_new_collection()
self._current_collection = self._generate_directory_info(collection_id_info)

def clear(self) -> None:
self._current_collection = None
try:
collection_id_info = await self._client.create_new_collection()
self._current_collection = self._generate_directory_info(collection_id_info)
except Exception as e:
self._current_collection = None
raise e

def _generate_directory_info(
self,
Expand Down
1 change: 0 additions & 1 deletion src/blueapi/preprocessors/attach_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def attach_metadata(
yield from bps.wait_for([provider.update])
directory_info: DirectoryInfo = provider()
yield from bpp.inject_md_wrapper(plan, md={DATA_SESSION: directory_info.prefix})
provider.clear()


attach_metadata_decorator = make_decorator(attach_metadata)
2 changes: 1 addition & 1 deletion tests/preprocessors/test_attach_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def test_visit_directory_provider_fails_after_one_success(
provider,
)
client.always_fail()
with pytest.raises(Exception):
with pytest.raises(ValueError):
collect_docs(
run_engine,
simple_run(detectors),
Expand Down

0 comments on commit a85331c

Please sign in to comment.