Skip to content

Crud separation#242

Merged
karlnyr merged 11 commits intorc5.0.0from
crud-separation
Mar 13, 2026
Merged

Crud separation#242
karlnyr merged 11 commits intorc5.0.0from
crud-separation

Conversation

@karlnyr
Copy link
Contributor

@karlnyr karlnyr commented Mar 13, 2026

Description

This pull request refactors several database access patterns and improves error handling across the codebase, especially in job creation and data scraping utilities. The main focus is on standardising method names for database operations, introducing more robust error handling for job creation, and updating the interfaces for interacting with the database. Additionally, some minor code cleanups and formatting improvements are included.

Primary function of PR

  • Hot-fix
  • Patch
  • Minor functionality improvement
  • New type of analysis
  • Backward-breaking functionality improvement
  • This change requires internal documents to be updated
  • This change requires another repository to be updated

Testing

  • bash /home/proj/production/servers/resources/hasta.scilifelab.se/install-microsalt-stage.sh BRANCHNAME
  • us
  • conda activate S_microSALT
  • microSALT analyse --input /path/to/fastq/ SAMPLEINFO_FILE

Test results

These are the results of the tests, and necessary conclusions, that prove the stability of the PR.

Sign-offs

  • Approved to run at Clinical-Genomics by @karlnyr or @Clinical-Genomics/micro

karlnyr added 11 commits March 12, 2026 16:39
- query_rec       -> read_records
- top_index       -> read_top_index
- get_columns     -> read_columns
- exists          -> read_exists
- get_version     -> read_version
- get_report      -> read_report
- list_unresolved -> read_unresolved
- alleles2st      -> read_st
- bestST          -> read_best_st
- bestAlleles     -> read_best_alleles
- get_unique_alleles -> read_unique_alleles

All call sites updated across utils/, cli.py, and tests/.
- setPredictor -> set_predictor
- sync_novel   -> set_novel_st
- rm_novel     -> set_novel_ignored
- set_report   already correct

upd_rec kept as generic updater for profile table operations.
All call sites updated.
- purge_rec -> delete_records

All call sites updated.
Add typed per-model methods for ORM tables:
- _add_orm_record(): shared private helper (replaces ORM path of add_rec)
- add_sample/project/seq_type/resistance/expac/report/collection/version()
- update_sample() — includes CG_ID_sample cascade to child tables
- update_project() / update_version()
- delete_sample() / delete_project() / delete_collection()

Old generic methods (add_rec ORM path, upd_rec, delete_records) still
present; callers migrated in next commit.
…llers of add_rec/upd_rec/delete_records now use the typed per-model\nequivalents (add_sample, add_version, add_report, update_sample,\ndelete_sample, delete_project, delete_collection). The only remaining\nadd_rec call is the ProfileTable (non-ORM) path in set_predictor.
…le only\n\n- Strip ORM path from add_rec; it now only handles non-ORM Table objects (ProfileTable / novel tables)\n- Remove upd_rec entirely (no remaining callers)\n- Remove delete_records entirely (no remaining callers)\n- Update tests: replace remaining upd_rec/delete_records/add_rec-with-string calls with typed per-model methods; drop test_add_rec_unknown_table which tested removed ORM fallback behaviour
…ion helpers\n\n- add_sample/project/seq_type/resistance/expac/report/collection/version(**kwargs)\n are now pure factory functions that construct and return the ORM object;\n callers are responsible for add_to_session() and commit_session()\n- add_to_session(obj): coerces string DateTime fields, skips silently if PK\n already exists, then stages the object\n- commit_session(): thin wrapper around session.commit()\n- Remove _add_orm_record helper\n- Update all callers (scraper, job_creator, conftest, tests) to\n factory(**kwargs) -> add_to_session -> commit_session pattern
- Introduced JobCreationError for better error management in job creation processes.
- Removed unused date_ordered field from Projects model.
- Cleaned up and organized imports across multiple files.
- Updated sampleinfo_projects.json to remove date_ordered entries.
- Refactored methods in Job_Creator to raise JobCreationError when sample information is missing.
- Improved type hints and code readability in various functions.
@karlnyr karlnyr requested a review from a team as a code owner March 13, 2026 13:28
@karlnyr karlnyr merged commit 8dcda7c into rc5.0.0 Mar 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant