Skip to content

Commit f54e8ab

Browse files
committed
Remove the need for an ispyb environment variable
1 parent e4cb4ce commit f54e8ab

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/murfey/server/ispyb.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import datetime
44
import logging
5-
import os
65
from typing import Callable, List, Optional
76

87
import ispyb
@@ -31,9 +30,11 @@
3130
url,
3231
)
3332

33+
from murfey.util.config import get_security_config
3434
from murfey.util.models import FoilHoleParameters, GridSquareParameters, Sample, Visit
3535

3636
log = logging.getLogger("murfey.server.ispyb")
37+
security_config = get_security_config()
3738

3839
try:
3940
Session = sqlalchemy.orm.sessionmaker(
@@ -60,7 +61,11 @@ def __init__(self, transport_type):
6061
self.transport = workflows.transport.lookup(transport_type)()
6162
self.transport.connect()
6263
self.feedback_queue = ""
63-
self.ispyb = ispyb.open() if os.getenv("ISPYB_CREDENTIALS") else None
64+
self.ispyb = (
65+
ispyb.open(credentials=security_config.ispyb_credentials)
66+
if security_config.ispyb_credentials
67+
else None
68+
)
6469
self._connection_callback: Callable | None = None
6570

6671
def reconnect(self):

src/murfey/util/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class Security(BaseModel):
9494
auth_type: Literal["password", "cookie"] = "password"
9595
cookie_key: str = ""
9696
feedback_queue: str = "murfey_feedback"
97+
ispyb_credentials: Optional[str] = None
9798

9899

99100
def security_from_file(config_file_path: Path) -> Security:

0 commit comments

Comments
 (0)