Skip to content

Commit

Permalink
Also force fix_com and fix_orientation to be true
Browse files Browse the repository at this point in the history
  • Loading branch information
bennybp committed Jan 7, 2024
1 parent d857947 commit 4ae04dc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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 ###
6 changes: 4 additions & 2 deletions qcfractal/qcfractal/components/molecules/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion qcfractal/qcfractal/components/molecules/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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):
Expand Down

0 comments on commit 4ae04dc

Please sign in to comment.