Skip to content

Commit 838720f

Browse files
committed
'murfey_db_credentials', and 'rabbit_mq_credentials' should be mandatory fields, but have type Optional[Path]
1 parent a69aa2a commit 838720f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/murfey/server/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ def run():
294294
# Run in demo mode with no connections set up
295295
os.environ["MURFEY_DEMO"] = "1"
296296
else:
297+
if not global_config.rabbitmq_credentials:
298+
raise FileNotFoundError("No RabbitMQ credentials file provided")
297299
# Load RabbitMQ configuration and set up the connection
298300
PikaTransport().load_configuration_file(global_config.rabbitmq_credentials)
299301
_set_up_transport("PikaTransport")

src/murfey/util/config.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ class MachineConfig(BaseModel):
380380
"""
381381
# Security-related keys
382382
global_configuration_path: Optional[Path] = Field(
383-
default=None,
384383
description=(
385384
"Full file path to the YAML file containing the configurations for the "
386385
"Murfey server."
@@ -493,9 +492,7 @@ def machine_config_from_file(
493492

494493
class GlobalConfig(BaseModel):
495494
# Database connection settings
496-
rabbitmq_credentials: str
497495
murfey_db_credentials: Optional[Path] = Field(
498-
default=None,
499496
description=(
500497
"Full file path to where Murfey's SQL database credentials are stored. "
501498
"This is typically a YAML file."
@@ -518,6 +515,7 @@ class GlobalConfig(BaseModel):
518515
)
519516

520517
# RabbitMQ settings
518+
rabbitmq_credentials: Optional[Path]
521519
feedback_queue: str = Field(
522520
default="murfey_feedback",
523521
description=(
@@ -540,12 +538,13 @@ class GlobalConfig(BaseModel):
540538
auth_key: str = ""
541539
auth_algorithm: str = ""
542540
cookie_key: str = ""
543-
544541
session_validation: str = ""
545542
session_token_timeout: Optional[int] = (
546543
None # seconds; typically the length of a microscope session plus a bit
547544
)
548545
allow_origins: list[str] = ["*"] # Restrict to only certain hostnames
546+
547+
# Graylog settings
549548
graylog_host: str = ""
550549
graylog_port: Optional[int] = None
551550

@@ -595,10 +594,11 @@ def get_global_config() -> GlobalConfig:
595594
machine_config = get_machine_config(instrument_name=os.getenv("BEAMLINE"))[
596595
os.getenv("BEAMLINE", "")
597596
]
598-
if machine_config.global_configuration_path:
599-
return global_config_from_file(machine_config.global_configuration_path)
597+
if not machine_config.global_configuration_path:
598+
raise FileNotFoundError("No global configuration file provided")
599+
return global_config_from_file(machine_config.global_configuration_path)
600600
return GlobalConfig(
601-
rabbitmq_credentials="",
601+
rabbitmq_credentials=None,
602602
session_validation="",
603603
murfey_db_credentials=None,
604604
crypto_key="",

0 commit comments

Comments
 (0)