Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to sqlalchemy version 2 #222

Merged
merged 7 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .github/workflows/update-orm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
path: dist/

- uses: shogo82148/actions-setup-mysql@v1
if: ${{ steps.checkUpdate.outputs.needsUpdate == 'true' }}
with:
distribution: 'mariadb'
mysql-version: '10.6'
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ keywords = ["ISPyB", "database"]
requires-python = ">=3.7"
readme = "README.md"
license = { text = "Apache License 2.0" }
dependencies = ["mysql-connector-python>=8.0.32", "sqlalchemy<2", "tabulate"]
dependencies = ["mysql-connector-python>=8.0.32", "sqlalchemy>=2", "tabulate"]
stephen-riggs marked this conversation as resolved.
Show resolved Hide resolved

[project.urls]
Documentation = "https://ispyb.readthedocs.io"
Expand Down
2 changes: 1 addition & 1 deletion requirements_orm.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mysql-connector-python>=8.0.32
sqlacodegen<3
sqlalchemy<2
sqlalchemy>=2
stephen-riggs marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 8 additions & 8 deletions src/ispyb/cli/last_data_collections_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ def get_last_data_collections_on(beamlines, db_session, limit=10, latest_dcid=No
db_session.query(BLSession, DataCollection, GridInfo, Proposal)
.options(
Load(DataCollection).load_only(
"dataCollectionId",
"fileTemplate",
"imageDirectory",
"numberOfImages",
"startTime",
DataCollection.dataCollectionId,
DataCollection.fileTemplate,
DataCollection.imageDirectory,
DataCollection.numberOfImages,
DataCollection.startTime,
),
Load(Proposal).load_only("proposalCode", "proposalNumber"),
Load(BLSession).load_only("beamLineName", "visit_number"),
Load(GridInfo).load_only("steps_x", "steps_y"),
Load(Proposal).load_only(Proposal.proposalCode, Proposal.proposalNumber),
Load(BLSession).load_only(BLSession.beamLineName, BLSession.visit_number),
Load(GridInfo).load_only(GridInfo.steps_x, GridInfo.steps_y),
)
.join(
BLSession,
Expand Down
3 changes: 1 addition & 2 deletions src/ispyb/sqlalchemy/_auto_db_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
TINYINT,
VARCHAR,
)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy.orm import declarative_base, relationship

Base = declarative_base()
metadata = Base.metadata
Expand Down