Skip to content

Commit

Permalink
Enforce inst/det name uniqueness
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaytan committed Aug 29, 2024
1 parent 9b5c1a2 commit 3ea0c1a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/nsls2api/services/beamline_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,18 @@ async def add_detector(
manufacturer=manufacturer,
)

current_detector_names = (
detector.name for detector in beamlines.detectors
)
current_directory_names = (
detector.directory_name for detector in beamline.detectors
)
if directory_name in current_directory_names:
if detector_name in current_detector_names:
logger.info(
f"Detector with name {detector_name} already exists in beamline {beamline_name}"
)
return None:
elif directory_name in current_directory_names:
logger.info(
f"Detector with directory name {directory_name} already exists in beamline {beamline_name}"
)
Expand Down

0 comments on commit 3ea0c1a

Please sign in to comment.