Skip to content

Commit

Permalink
Merge pull request #198 from wtsi-npg/devel
Browse files Browse the repository at this point in the history
pull from devel to master to create release 2.0.0
  • Loading branch information
mgcam authored Feb 20, 2024
2 parents f4c9039 + 84aca35 commit 78a51ae
Show file tree
Hide file tree
Showing 12 changed files with 784 additions and 715 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed

* The correctness of data in the 'properties' column of the
LangQC 'sub_product' database table is no longer guaranteed
because of the changes introduced in v. 5.0.0 of https://github.com/wtsi-npg/npg_id_generation
The column is made nullable and then dropped. The ORM for
the LangQC database is updated accordingly.

* The production code no longer depends on the npg_id_generation
package, therefore this dependency was moved to the dev section
of pyproject.toml. The package is still used by tests and test
fixtures.

* Upgraded some of dev dependencies: npg_id_generation to 5.0.1,
alembic to 1.13.0 or later.

* Regenerated poetry.lock file.

## [1.5.1] - 2024-01-25

### Changed
Expand Down
26 changes: 20 additions & 6 deletions alembic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Planned changes should be applied in [lang_qc/db/qc_schema.py](../lang_qc/db/qc_schema.py).
We recommend doing this manually.

Changes to unit test,test fixtures and the source code should be applied as
Changes to unit tests, test fixtures and the source code should be applied as
appropriate.

## Creating migrations for the QC database schema
Expand All @@ -19,13 +19,27 @@ Set `ALEMBIC_DB_URL` env. variable to the SQLAlchemy URL for the database you
want to operate on. The format is `driver://user:pass@host:port/dbname`, where
for MySQL and our software stack the driver is `mysql+pymysql`.

Ensure `alembic` in on your PATH. Create a revision:
Ensure `alembic` is on your PATH. Run all commands from the root of the
repository, where the configuration for alembic `alembic.ini` resides.

```alembic revision -m 'This is a revision description'```
Create a revision:

Define explicitly SQL statements that have to be executed both for the
`upgrade` and `downgrade` function definitions in the generated script.
Call execution of these statements, one at a time. Executing multiple
```
# This example command generates alembic/versions/2.0.0_drop_json_properties_column.py
# python script, which contains an empty template for defining the migration.
alembic revision -m 'drop_json_properties_column' --rev-id 2.0.0 --head 3814003a709a
```

If `--rev_id` is not specified, `alembic` generates a random id for the migration,
which does not present the problem immideately, but makes it difficult long term to
understand the order of migrations and identify the latest migration. Set `--rev_id`
to the next release version.

The value of the `--head` argument is the version of the previous migration.

Edit the newly generated script. Define explicitly SQL statements that have to be
executed both for the `upgrade` and `downgrade` function definitions in the
script. Call execution of these statements, one at a time. Executing multiple
statements in one go does not work. See examples in the [versions](./versions)
directory.

Expand Down
29 changes: 29 additions & 0 deletions alembic/versions/2.0.0_drop_json_properties_column.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""drop_json_properties_column
Revision ID: 2.0.0
Revises: 3814003a709a
Create Date: 2024-02-20 10:51:40.326882
"""
from alembic import op

# revision identifiers, used by Alembic.
revision = "2.0.0"
down_revision = "3814003a709a"
branch_labels = None
depends_on = None


def upgrade() -> None:
sql = """
ALTER TABLE sub_product DROP COLUMN properties
"""
op.execute(sql)


def downgrade() -> None:
sql = """
ALTER TABLE sub_product ADD COLUMN properties JSON DEFAULT NULL AFTER value_attr_three
"""
op.execute(sql)
pass
28 changes: 28 additions & 0 deletions alembic/versions/3814003a709a_make_column_properties_nullable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Make column properties nullable
Revision ID: 3814003a709a
Revises: 36952df5b8ba
Create Date: 2024-02-02 14:30:20.079955
"""
from alembic import op

# revision identifiers, used by Alembic.
revision = "3814003a709a"
down_revision = "36952df5b8ba"
branch_labels = None
depends_on = None


def upgrade() -> None:
sql = """
ALTER TABLE sub_product MODIFY properties JSON DEFAULT NULL
"""
op.execute(sql)


def downgrade() -> None:
sql = """
ALTER TABLE sub_product MODIFY properties JSON NOT NULL
"""
op.execute(sql)
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "npg-longue-vue",
"version": "1.5.1",
"version": "2.0.0",
"description": "UI for LangQC",
"author": "Kieron Taylor <[email protected]>",
"license": "GPL-3.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion lang_qc/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.5.1"
__version__ = "2.0.0"
5 changes: 0 additions & 5 deletions lang_qc/db/helper/well.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
for interaction with the LangQC database.
"""

from npg_id_generation.pac_bio import PacBioEntity
from sqlalchemy import select
from sqlalchemy.orm import Session

Expand Down Expand Up @@ -84,9 +83,6 @@ def _create_well(
product_attr_pn = session.execute(
select(SubProductAttr).where(SubProductAttr.attr_name == "plate_number")
).scalar_one()
product_json = PacBioEntity(
run_name=run_name, well_label=well_label, plate_number=plate_number
).model_dump_json()

# TODO: in future for composite products we have to check whether any of
# the `sub_product` table entries we are linking to already exist.
Expand All @@ -103,7 +99,6 @@ def _create_well(
value_attr_three=str(plate_number)
if plate_number is not None
else None,
properties=product_json,
properties_digest=id_product,
)
],
Expand Down
1 change: 0 additions & 1 deletion lang_qc/db/qc_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ class SubProduct(Base):
value_attr_two = Column(String(20), nullable=False, index=True)
id_attr_three = Column(INTEGER, nullable=True, index=True)
value_attr_three = Column(String(20), nullable=True, index=True)
properties = Column(JSON, nullable=False)
properties_digest = Column(CHAR(64), nullable=False, unique=True)
tags = Column(String(255), index=True)

Expand Down
Loading

0 comments on commit 78a51ae

Please sign in to comment.