From 4ae04dcd30209300f6af54ec18d0b376b57bf087 Mon Sep 17 00:00:00 2001 From: Benjamin Pritchard Date: Sat, 6 Jan 2024 19:21:49 -0500 Subject: [PATCH] Also force fix_com and fix_orientation to be true --- ...emove_explicit_fix__columns_in_molecule.py | 32 +++++++++++++++++++ .../components/molecules/db_models.py | 6 ++-- .../components/molecules/test_socket.py | 6 +++- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 qcfractal/qcfractal/alembic/versions/2024-01-06-49cfda6eb87e_remove_explicit_fix__columns_in_molecule.py diff --git a/qcfractal/qcfractal/alembic/versions/2024-01-06-49cfda6eb87e_remove_explicit_fix__columns_in_molecule.py b/qcfractal/qcfractal/alembic/versions/2024-01-06-49cfda6eb87e_remove_explicit_fix__columns_in_molecule.py new file mode 100644 index 000000000..7c97718bc --- /dev/null +++ b/qcfractal/qcfractal/alembic/versions/2024-01-06-49cfda6eb87e_remove_explicit_fix__columns_in_molecule.py @@ -0,0 +1,32 @@ +"""remove explicit fix_ columns in molecule + +Revision ID: 49cfda6eb87e +Revises: de44b1b34097 +Create Date: 2024-01-06 19:18:04.534992 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "49cfda6eb87e" +down_revision = "de44b1b34097" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("molecule", "fix_orientation") + op.drop_column("molecule", "fix_com") + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column("molecule", sa.Column("fix_com", sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column("molecule", sa.Column("fix_orientation", sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.execute(sa.text("UPDATE molecule SET fix_com = True, fix_orientation = True")) + op.alter_column("molecule", "fix_com", nullable=False) + op.alter_column("molecule", "fix_orientation", nullable=False) + # ### end Alembic commands ### diff --git a/qcfractal/qcfractal/components/molecules/db_models.py b/qcfractal/qcfractal/components/molecules/db_models.py index 8ec66a5ea..1a456fd93 100644 --- a/qcfractal/qcfractal/components/molecules/db_models.py +++ b/qcfractal/qcfractal/components/molecules/db_models.py @@ -51,10 +51,12 @@ class MoleculeORM(BaseORM): fragment_multiplicities = Column(JSON) # Column(ARRAY(Integer)) # Orientation & symmetry - fix_com = Column(Boolean, nullable=False, default=True) - fix_orientation = Column(Boolean, nullable=False, default=True) fix_symmetry = Column(String) + # These are always forced to be true + fix_com = column_property(True) + fix_orientation = column_property(True) + # Molecule is always validated before going in the database validated = column_property(True) diff --git a/qcfractal/qcfractal/components/molecules/test_socket.py b/qcfractal/qcfractal/components/molecules/test_socket.py index 944c3df24..799a2c5ef 100644 --- a/qcfractal/qcfractal/components/molecules/test_socket.py +++ b/qcfractal/qcfractal/components/molecules/test_socket.py @@ -9,7 +9,7 @@ from qcfractal.db_socket import SQLAlchemySocket -def test_molecules_socket_get_validated(storage_socket: SQLAlchemySocket): +def test_molecules_socket_validated_fix(storage_socket: SQLAlchemySocket): water = load_molecule_data("water_dimer_minima") hooh = load_molecule_data("hooh") @@ -18,7 +18,11 @@ def test_molecules_socket_get_validated(storage_socket: SQLAlchemySocket): mols = storage_socket.molecules.get(ids) assert mols[0]["validated"] is True + assert mols[0]["fix_com"] is True + assert mols[0]["fix_orientation"] is True assert mols[1]["validated"] is True + assert mols[1]["fix_com"] is True + assert mols[1]["fix_orientation"] is True def test_molecules_socket_get_proj(storage_socket: SQLAlchemySocket):