Set up all things for first query

This commit is contained in:
Stephan Porada 2019-11-07 10:45:12 +01:00
parent 414ebc73ff
commit 47440880d5
4 changed files with 42 additions and 6 deletions

View File

@ -27,13 +27,13 @@ def recv_query(message):
def observe_corpus_analysis_connection(app, corpus_id, session_id):
logger = logging.getLogger(__name__)
corpus = Corpus.query.filter_by(id=corpus_id).first()
with app.app_context():
cqi_client = CQiClient(host='172.25.0.2')
cqi_client = CQiClient(host=corpus.analysis_container_ip)
while session_id in connected_sessions:
logger.warning(cqi_client.ctrl_ping())
logger.warning('Run container, run!')
socketio.sleep(3)
corpus = Corpus.query.filter_by(id=corpus_id).first()
corpus.status = 'stop analysis'
db.session.commit()
logger.warning('Stop container, stop!')

View File

@ -442,7 +442,8 @@ class Corpus(db.Model):
status = db.Column(db.String(16))
title = db.Column(db.String(32))
user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
analysis_ip = db.Column(db.String(16))
analysis_container_ip = db.Column(db.String(16))
analysis_container_name = db.Column(db.String(32))
# Relationships
files = db.relationship('CorpusFile',
backref='corpus',

View File

@ -61,11 +61,14 @@
statusElement.classList.remove(...Object.values(CorpusList.STATUS_COLORS));
statusElement.classList.add(CorpusList.STATUS_COLORS[status] || CorpusList.STATUS_COLORS['default']);
statusElement.innerText = status;
if (status === 'prepared' || status === 'start analysis' || status === 'analysing') {
var analyseBtn = document.getElementById('analyse');
var analyseBtn = document.getElementById('analyse');
if (status === 'prepared') {
analyseBtn.classList.remove('hide', 'disabled');
} else if (status === 'analysing' || status === 'start analysis' || status === 'stop analysis') {
analyseBtn.classList.remove('hide');
analyseBtn.classList.add('disabled');
}
if (status === 'prepared' || status === 'start analysis' || status === 'analysing') {
if (status === 'prepared' || status === 'start analysis' || status === 'analysing' || status === 'stop analysis') {
var prepareBtn = document.getElementById('prepare');
prepareBtn.classList.add('hide');
}

View File

@ -0,0 +1,32 @@
"""empty message
Revision ID: 776761fb7466
Revises: 0aa38a7973c5
Create Date: 2019-11-07 08:34:01.676055
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '776761fb7466'
down_revision = '0aa38a7973c5'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('corpora', sa.Column('analysis_container_ip', sa.String(length=16), nullable=True))
op.add_column('corpora', sa.Column('analysis_container_name', sa.String(length=32), nullable=True))
op.drop_column('corpora', 'analysis_ip')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('corpora', sa.Column('analysis_ip', sa.VARCHAR(length=16), autoincrement=False, nullable=True))
op.drop_column('corpora', 'analysis_container_name')
op.drop_column('corpora', 'analysis_container_ip')
# ### end Alembic commands ###