Skip to content

Commit bb60ac9

Browse files
committed
Passed ISPyB credentials in to 'url()' function to remove the need for an ISPYB_CREDENTIALS environment variable
1 parent 368dd2f commit bb60ac9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/murfey/server/ispyb.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@
3939

4040
try:
4141
Session = sqlalchemy.orm.sessionmaker(
42-
bind=sqlalchemy.create_engine(url(), connect_args={"use_pure": True})
42+
bind=sqlalchemy.create_engine(
43+
url(credentials=security_config.ispyb_credentials),
44+
connect_args={"use_pure": True},
45+
)
4346
)
47+
log.info("Loaded ISPyB database session")
4448
except AttributeError:
49+
log.error("Error loading ISPyB session", exc_info=True)
4550
Session = lambda: None
4651

4752

@@ -67,6 +72,8 @@ def __init__(self, transport_type: Literal["PikaTransport"]):
6772
if security_config.ispyb_credentials
6873
else None
6974
)
75+
if self.ispyb is not None:
76+
print("Loaded ISPyB databse")
7077
self._connection_callback: Callable | None = None
7178

7279
def reconnect(self):
@@ -632,6 +639,7 @@ def get_all_ongoing_visits(
632639
microscope: str, db: sqlalchemy.orm.Session | None
633640
) -> list[Visit]:
634641
if db is None:
642+
print("No database found")
635643
return []
636644
query = (
637645
db.query(BLSession)

0 commit comments

Comments
 (0)