Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/murfey/server/ispyb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import datetime
import logging
import os
from typing import Callable, List, Literal, Optional

import ispyb
Expand Down Expand Up @@ -31,9 +30,11 @@
url,
)

from murfey.util.config import get_security_config
from murfey.util.models import FoilHoleParameters, GridSquareParameters, Sample, Visit

log = logging.getLogger("murfey.server.ispyb")
security_config = get_security_config()

try:
Session = sqlalchemy.orm.sessionmaker(
Expand All @@ -60,7 +61,11 @@
self.transport = workflows.transport.lookup(transport_type)()
self.transport.connect()
self.feedback_queue = ""
self.ispyb = ispyb.open() if os.getenv("ISPYB_CREDENTIALS") else None
self.ispyb = (

Check warning on line 64 in src/murfey/server/ispyb.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/ispyb.py#L64

Added line #L64 was not covered by tests
ispyb.open(credentials=security_config.ispyb_credentials)
if security_config.ispyb_credentials
else None
)
self._connection_callback: Callable | None = None

def reconnect(self):
Expand Down
5 changes: 3 additions & 2 deletions src/murfey/util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ def from_file(config_file_path: Path, instrument: str = "") -> Dict[str, Machine


class Security(BaseModel):
rabbitmq_credentials: str
murfey_db_credentials: str
murfey_db_credentials: Path
crypto_key: str
auth_key: str = ""
auth_algorithm: str = ""
Expand All @@ -94,9 +93,11 @@ class Security(BaseModel):
session_token_timeout: Optional[int] = None
auth_type: Literal["password", "cookie"] = "password"
cookie_key: str = ""
rabbitmq_credentials: Path
feedback_queue: str = "murfey_feedback"
graylog_host: str = ""
graylog_port: Optional[int] = None
ispyb_credentials: Optional[Path] = None

@validator("graylog_port")
def check_port_present_if_host_is(
Expand Down
Loading