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

Migrate mri_scanner to the new database abstraction #1232

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

maximemulder
Copy link
Contributor

Builds on top of #1224. This PR migrates lib.database_lib.mri_scanner to the new database abstraction, and migrates the existing code that uses it to the new abstraction.

This PR does not migrate the configuration file that still indirectly uses this code, but this can be done in a follow-up PR (or this PR if wanted).

@maximemulder maximemulder force-pushed the sqlalchemy_mri_scanner branch 6 times, most recently from 08f95d1 to ab1289f Compare February 19, 2025 03:06
@maximemulder maximemulder marked this pull request as ready for review February 19, 2025 03:11
@maximemulder maximemulder changed the title Sqlalchemy mri scanner Migrate mri_scanner to the new database abstraction Feb 19, 2025
@maximemulder maximemulder added Refactoring Area: ORM PR or issue related to the SQLAlchemy integration Difficulty: Simple PR or issue that should be easy to implement, review, or test labels Feb 19, 2025
@cmadjar
Copy link
Collaborator

cmadjar commented Feb 19, 2025

@maximemulder branch has conflicts after merging #1224

@maximemulder maximemulder force-pushed the sqlalchemy_mri_scanner branch from ab1289f to 5e375a9 Compare February 20, 2025 04:05
@maximemulder
Copy link
Contributor Author

@cmadjar rebased !

Comment on lines +64 to +74
# TODO: Move this function to a more appropriate place.
def generate_new_cand_id(db: Database) -> int:
"""
Generate a new random CandID that is not already in the database.
"""

while True:
cand_id = random.randint(100000, 999999)
candidate = try_get_candidate_with_cand_id(db, cand_id)
if candidate is None:
return cand_id
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually I'd like to move this function to lib.candidate, but this is future work. I think with the changes in the incremental BIDS importer it might become possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: ORM PR or issue related to the SQLAlchemy integration Difficulty: Simple PR or issue that should be easy to implement, review, or test Refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants