Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

services:
mysql:
image: mysql:8.0.35
image: mysql:8.4
ports:
- 3306:3306
env:
Expand Down
21 changes: 19 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,32 @@
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## [1.0.0] - 2026-04-24

### Changed

* Upgraded MySQL version for GitHub CI to 8.4
* Updated the ORM to reflect [changes](https://github.com/wtsi-npg/npg_tracking/pull/969)
to the production database.
* Regenerated the ORM with the current (4.0.3) version of `sqlacodegen`.
* Renamed `tests/test_schema.py` to `tests/test_retrieval.py` to reflect the
module name that is being tested.

### Added

* `validate_runfolder` function to npgtracking.db.retrieval

## [0.2.0] - 2025-12-12

### Added

* get_run_by_id function added to retrieval module
* `get_run_by_id` function added to retrieval module

### Fixed

* run.batch_id is now a varchar
* `run.batch_id` is now a varchar

## [0.1.1] - 2025-12-11

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The code in this package was tested for read-only operations. Business logic
for `create` and `update` operation for different database tables is implemented
in the Perl package. We advise against performing `write` operations using this ORM.

This ORM has been auto-generated with [`sqlacodegen 3.1.1`](https://pypi.org/project/sqlacodegen/3.1.1/)
This ORM has been auto-generated with [`sqlacodegen 4.0.3`](https://pypi.org/project/sqlacodegen/4.0.3/)

```
sqlacodegen --generator declarative mysql+pymysql://user:pass@host:port/dbname > src/npgtracking/db/schema.py
Expand Down
22 changes: 22 additions & 0 deletions src/npgtracking/db/retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,25 @@ def get_run_by_id(
raise ValueError("Can't get one run without an argument")
result = session.execute(statement).scalar_one_or_none()
return result


def validate_runfolder(session: Session, id_run: int, runfolder_name: str) -> bool:
"""Validates the runfolder name against the run ID.

Errors if run with the given ID does not exist.

Args:
session :
Database session
id_run :
Tracking run ID
runfolder_name :
Runfolder name
Returns:
`True` if the runfolder name and run id belong to the same run, `False`
otherwise.
"""
run = session.execute(select(Run).where(Run.id_run == id_run)).scalar()
if not run:
raise ValueError(f"Run with ID {id_run} does not exist.")
return run.folder_name == runfolder_name
Loading