nopaque/app/cli/corpus.py

24 lines
711 B
Python
Raw Normal View History

2023-05-11 14:33:21 +00:00
from app.models import Corpus, CorpusStatus
def init_app(app):
@app.cli.group('corpus')
def corpus():
''' Corpus commands. '''
pass
@corpus.command('dismantle')
def dismantle():
''' Dismantle built corpora. '''
status = [
CorpusStatus.QUEUED,
CorpusStatus.BUILDING,
CorpusStatus.BUILT,
CorpusStatus.STARTING_ANALYSIS_SESSION,
CorpusStatus.RUNNING_ANALYSIS_SESSION,
CorpusStatus.CANCELING_ANALYSIS_SESSION
]
for corpus in [x for x in Corpus.query.all() if x.status in status]:
corpus.status = CorpusStatus.SUBMITTED
corpus.num_analysis_sessions = 0