Make inner package imports relative

This commit is contained in:
Patrick Jentsch 2020-03-27 12:06:11 +01:00
parent 3bbe45d015
commit 4294c2854b
29 changed files with 37 additions and 149 deletions

View File

@ -1,50 +0,0 @@
# Corpus Analysis
## Start einer Session
```javascript
nopaque.socket.emit("corpus_analysis_init", <corpusId>);
<corpusId> ~ number
// Show init loading modal
nopaque.socket.on("corpus_analysis_init", <response>);
<response> ~ {"code": <code>, "msg": <message>}
<code> ~ number // HTTP status code
<msg> ~ string
// Hide init loading modal
```
## Ausführen einer Suchanfrage
Ergebnisse werden Stückchenweise als "chunks" übertragen.
```javascript
nopaque.socket.emit("corpus_analysis_query", <query>);
<query> ~ string
// Clear result data store and list
result = {"query": <query>};
// Hide query result card
// Show query loading card
nopaque.socket.on("corpus_analysis_query", <response>);
<response>: {"code": <code>, "result": <result>}
<code> ~ number // Error, Success
<result> ~ {"matches": [<cpos>, ...],
"num_matches": <num_matches>,
"cpos_lookup": {<cpos>: <token>, ...},
"text_lookup": {<textId>: <text>, ...}}
<cpos> ~ number
<num_matches> ~ number
<token> ~ {"word": <word>, "lemma": <lemma>, "simple_pos": <simple_pos>, "pos": <pos>, "ner": <ner>, "text": <textId>, "s": <sId>}
<word> ~ string
<lemma> ~ string
<simple_pos> ~ string
<pos> ~ string
<ner> ~ string
<textId> ~ number
<sId> ~ number
<text> ~ {"author": <author>, "title": <text>, ...}
<s> ~ string
// Process response
// Hide query result card
// Show query loading card
```

View File

@ -2,4 +2,4 @@ from flask import Blueprint
admin = Blueprint('admin', __name__) admin = Blueprint('admin', __name__)
from . import views from . import views # noqa

View File

@ -1,8 +1,8 @@
from app.models import Role, User
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import (BooleanField, SelectField, StringField, SubmitField, from wtforms import (BooleanField, SelectField, StringField, SubmitField,
ValidationError) ValidationError)
from wtforms.validators import DataRequired, Email, Length, Regexp from wtforms.validators import DataRequired, Email, Length, Regexp
from ..models import Role, User
class EditUserForm(FlaskForm): class EditUserForm(FlaskForm):

View File

@ -1,13 +1,13 @@
from app import db
from app.decorators import admin_required
from app.models import Role, User
from app.profile.background_functions import delete_user_
from flask import current_app, flash, redirect, render_template, url_for from flask import current_app, flash, redirect, render_template, url_for
from flask_login import login_required from flask_login import login_required
from threading import Thread from threading import Thread
from . import admin from . import admin
from .forms import EditUserForm from .forms import EditUserForm
from .tables import AdminUserItem, AdminUserTable from .tables import AdminUserItem, AdminUserTable
from .. import db
from ..decorators import admin_required
from ..models import Role, User
from ..profile.background_functions import delete_user_
@admin.route('/') @admin.route('/')

View File

@ -2,4 +2,4 @@ from flask import Blueprint
auth = Blueprint('auth', __name__) auth = Blueprint('auth', __name__)
from . import views from . import views # noqa

View File

@ -1,4 +1,4 @@
from app.models import User from ..models import User
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import (BooleanField, PasswordField, StringField, SubmitField, from wtforms import (BooleanField, PasswordField, StringField, SubmitField,
ValidationError) ValidationError)

View File

@ -1,12 +1,12 @@
from app import db, logger
from app.email import send_email
from app.models import User
from flask import (current_app, flash, redirect, render_template, request, from flask import (current_app, flash, redirect, render_template, request,
url_for) url_for)
from flask_login import current_user, login_user, login_required, logout_user from flask_login import current_user, login_user, login_required, logout_user
from . import auth from . import auth
from .forms import (LoginForm, ResetPasswordForm, ResetPasswordRequestForm, from .forms import (LoginForm, ResetPasswordForm, ResetPasswordRequestForm,
RegistrationForm) RegistrationForm)
from .. import db
from ..email import send_email
from ..models import User
import os import os
import shutil import shutil

View File

@ -2,4 +2,4 @@ from flask import Blueprint
corpora = Blueprint('corpora', __name__) corpora = Blueprint('corpora', __name__)
from . import events, views from . import events, views # noqa

View File

@ -1,4 +1,4 @@
from app.models import Corpus, CorpusFile from ..models import Corpus, CorpusFile
def delete_corpus_(app, corpus_id): def delete_corpus_(app, corpus_id):

View File

@ -1,10 +1,10 @@
from app import db, logger, socketio
from app.decorators import socketio_login_required
from app.events import connected_sessions
from app.models import Corpus, User
from .cqi import CQiClient
from flask import current_app, request from flask import current_app, request
from flask_login import current_user from flask_login import current_user
from .cqi import CQiClient
from .. import db, logger, socketio
from ..decorators import socketio_login_required
from ..events import connected_sessions
from ..models import Corpus, User
import math import math

View File

@ -1,5 +1,3 @@
from app import db, logger
from app.models import Corpus, CorpusFile
from flask import (abort, current_app, flash, redirect, request, from flask import (abort, current_app, flash, redirect, request,
render_template, url_for, send_from_directory) render_template, url_for, send_from_directory)
from flask_login import current_user, login_required from flask_login import current_user, login_required
@ -10,6 +8,8 @@ from .background_functions import (delete_corpus_, delete_corpus_file_,
edit_corpus_file_) edit_corpus_file_)
from .forms import (AddCorpusFileForm, AddCorpusForm, EditCorpusFileForm, from .forms import (AddCorpusFileForm, AddCorpusForm, EditCorpusFileForm,
QueryDownloadForm, QueryForm) QueryDownloadForm, QueryForm)
from .. import db
from ..models import Corpus, CorpusFile
import os import os

View File

@ -1,7 +1,7 @@
from functools import wraps
from flask import abort from flask import abort
from flask_login import current_user from flask_login import current_user
from flask_socketio import disconnect from flask_socketio import disconnect
from functools import wraps
from .models import Permission from .models import Permission

View File

@ -1,6 +1,6 @@
from threading import Thread
from flask import current_app, render_template from flask import current_app, render_template
from flask_mail import Message from flask_mail import Message
from threading import Thread
from . import mail from . import mail

View File

@ -2,4 +2,4 @@ from flask import Blueprint
jobs = Blueprint('jobs', __name__) jobs = Blueprint('jobs', __name__)
from . import views from . import views # noqa

View File

@ -1,4 +1,4 @@
from app.models import Job from ..models import Job
def delete_job_(app, job_id): def delete_job_(app, job_id):

View File

@ -1,10 +1,10 @@
from app.models import Job, JobInput, JobResult
from flask import (abort, current_app, flash, redirect, render_template, from flask import (abort, current_app, flash, redirect, render_template,
send_from_directory, url_for) send_from_directory, url_for)
from flask_login import current_user, login_required from flask_login import current_user, login_required
from threading import Thread from threading import Thread
from . import jobs from . import jobs
from .background_functions import delete_job_ from .background_functions import delete_job_
from ..models import Job, JobInput, JobResult
import os import os

View File

@ -2,10 +2,4 @@ from flask import Blueprint
main = Blueprint('main', __name__) main = Blueprint('main', __name__)
from . import errors, views from . import errors, views # noqa
from app.models import Permission
@main.app_context_processor
def inject_permissions():
return dict(Permission=Permission)

View File

@ -1,11 +1,10 @@
from app import logger
from app.auth.forms import LoginForm
from app.models import User
from flask import flash, redirect, render_template, url_for from flask import flash, redirect, render_template, url_for
from flask_login import login_required, login_user from flask_login import login_required, login_user
from . import main from . import main
from .forms import FeedbackForm from .forms import FeedbackForm
from .. import logger
from ..auth.forms import LoginForm
from ..models import User
@main.route('/', methods=['GET', 'POST']) @main.route('/', methods=['GET', 'POST'])
def index(): def index():

View File

@ -2,4 +2,4 @@ from flask import Blueprint
profile = Blueprint('profile', __name__) profile = Blueprint('profile', __name__)
from . import views from . import views # noqa

View File

@ -1,4 +1,4 @@
from app.models import User from ..models import User
def delete_user_(app, user_id): def delete_user_(app, user_id):

View File

@ -1,10 +1,10 @@
from app import db
from flask import current_app, flash, redirect, render_template, url_for from flask import current_app, flash, redirect, render_template, url_for
from flask_login import current_user, login_required, logout_user from flask_login import current_user, login_required, logout_user
from threading import Thread from threading import Thread
from . import profile from . import profile
from .background_functions import delete_user_ from .background_functions import delete_user_
from .forms import EditEmailForm, EditGeneralSettingsForm, EditPasswordForm from .forms import EditEmailForm, EditGeneralSettingsForm, EditPasswordForm
from .. import db
@profile.route('/settings', methods=['GET', 'POST']) @profile.route('/settings', methods=['GET', 'POST'])

View File

@ -2,4 +2,4 @@ from flask import Blueprint
services = Blueprint('services', __name__) services = Blueprint('services', __name__)
from . import views from . import views # noqa

View File

@ -1,14 +1,13 @@
from app import db
from app.jobs.forms import AddNLPJobForm, AddOCRJobForm, AddSetupFilesJobForm
from app.models import Job, JobInput
from flask import (abort, current_app, flash, make_response, render_template, from flask import (abort, current_app, flash, make_response, render_template,
url_for) url_for)
from flask_login import current_user, login_required from flask_login import current_user, login_required
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from . import services from . import services
from .. import db
from ..jobs.forms import AddNLPJobForm, AddOCRJobForm, AddSetupFilesJobForm
from ..models import Job, JobInput
import json import json
import os import os
from app import logger
SERVICES = {'corpus_analysis': {'name': 'Corpus analysis'}, SERVICES = {'corpus_analysis': {'name': 'Corpus analysis'},

View File

@ -1,5 +0,0 @@
from flask import Blueprint
test = Blueprint('test', __name__)
from . import events, views

View File

@ -1,23 +0,0 @@
from app import logger, socketio
from flask_login import login_required
from werkzeug.datastructures import FileStorage
from werkzeug.utils import secure_filename
from .forms import TestForm
import io
@socketio.on('submit-test-form')
@login_required
def recv_test_form(data):
logger.warning("data_received")
filename = secure_filename(data['file-wrapper']['name'])
stream = io.BytesIO(data['file-wrapper']['bytes'])
file = FileStorage(filename=filename, stream=stream)
data['file'] = file
test_form = TestForm(data=data)
if test_form.validate():
socketio.emit('submit-test-form', {'msg': {},
'status': 201})
else:
socketio.emit('submit-test-form', {'msg': test_form.errors,
'status': 400})

View File

@ -1,12 +0,0 @@
from flask_wtf import FlaskForm
from flask_wtf.file import FileAllowed, FileField, FileRequired
from wtforms import StringField, SubmitField
from wtforms.validators import DataRequired, Length
class TestForm(FlaskForm):
description = StringField('Description',
validators=[DataRequired(), Length(1, 255)])
file = FileField('File', validators=[FileAllowed(['txt'], 'Plain text only!'), FileRequired()])
submit = SubmitField()
title = StringField('Title', validators=[DataRequired(), Length(1, 32)])

View File

@ -1,12 +0,0 @@
from flask import render_template
from flask_login import login_required
from . import test
from .forms import TestForm
@test.route('/')
@login_required
def index():
test_form = TestForm()
return render_template('test/index.html.j2', title='Test',
test_form=test_form)

View File

@ -1,5 +1,5 @@
import eventlet import eventlet
eventlet.monkey_patch() eventlet.monkey_patch() # noqa: E261
from app import create_app, db, socketio from app import create_app, db, socketio
from app.models import Corpus, Job, Role, User from app.models import Corpus, Job, Role, User
from flask_migrate import Migrate from flask_migrate import Migrate

View File

@ -1,7 +1,5 @@
import re
import unittest import unittest
from app import create_app, db from app import create_app, db
from app.models import User, Role
class FlaskClientTestCase(unittest.TestCase): class FlaskClientTestCase(unittest.TestCase):