This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #511 from DiamondLightSource/510_readd_zocalo_time…
…_to_comment Restore writing the analysis time to comments
- Loading branch information
Showing
9 changed files
with
91 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from functools import partial | ||
from typing import Callable | ||
|
||
import ispyb.sqlalchemy | ||
import pytest | ||
from ispyb.sqlalchemy import DataCollection | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker | ||
|
||
from artemis.external_interaction.ispyb.store_in_ispyb import ( | ||
StoreInIspyb2D, | ||
StoreInIspyb3D, | ||
) | ||
from artemis.parameters import FullParameters | ||
from artemis.utils import Point3D | ||
|
||
ISPYB_CONFIG = "/dls_sw/dasc/mariadb/credentials/ispyb-dev.cfg" | ||
|
||
|
||
def get_current_datacollection_comment(Session: Callable, dcid: int) -> str: | ||
"""Read the 'comments' field from the given datacollection id's ISPyB entry. | ||
Returns an empty string if the comment is not yet initialised. | ||
""" | ||
try: | ||
with Session() as session: | ||
query = session.query(DataCollection).filter( | ||
DataCollection.dataCollectionId == dcid | ||
) | ||
current_comment: str = query.first().comments | ||
except Exception: | ||
current_comment = "" | ||
return current_comment | ||
|
||
|
||
@pytest.fixture | ||
def fetch_comment() -> Callable: | ||
url = ispyb.sqlalchemy.url(ISPYB_CONFIG) | ||
engine = create_engine(url, connect_args={"use_pure": True}) | ||
Session = sessionmaker(engine) | ||
return partial(get_current_datacollection_comment, Session) | ||
|
||
|
||
@pytest.fixture | ||
def dummy_params(): | ||
dummy_params = FullParameters() | ||
dummy_params.ispyb_params.upper_left = Point3D(100, 100, 50) | ||
dummy_params.ispyb_params.pixels_per_micron_x = 0.8 | ||
dummy_params.ispyb_params.pixels_per_micron_y = 0.8 | ||
dummy_params.ispyb_params.visit_path = "/dls/i03/data/2022/cm31105-5/" | ||
return dummy_params | ||
|
||
|
||
@pytest.fixture | ||
def dummy_ispyb(dummy_params) -> StoreInIspyb2D: | ||
return StoreInIspyb2D(ISPYB_CONFIG, dummy_params) | ||
|
||
|
||
@pytest.fixture | ||
def dummy_ispyb_3d(dummy_params) -> StoreInIspyb3D: | ||
return StoreInIspyb3D(ISPYB_CONFIG, dummy_params) |
51 changes: 0 additions & 51 deletions
51
src/artemis/external_interaction/system_tests/test_ispyb_dev_connection.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters