Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
8a607b6d
Commit
8a607b6d
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Multiple analyses sessions perfectly implemented.
parent
87b7f07d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/corpora/events.py
+13
-7
13 additions, 7 deletions
app/corpora/events.py
app/corpora/views.py
+3
-2
3 additions, 2 deletions
app/corpora/views.py
app/templates/corpora/corpus.html.j2
+2
-2
2 additions, 2 deletions
app/templates/corpora/corpus.html.j2
with
18 additions
and
11 deletions
app/corpora/events.py
+
13
−
7
View file @
8a607b6d
...
@@ -7,6 +7,7 @@ from .CQiWrapper.CQiWrapper import CQiWrapper
...
@@ -7,6 +7,7 @@ from .CQiWrapper.CQiWrapper import CQiWrapper
import
logging
import
logging
analysis_sessions
=
{}
analysis_clients
=
{}
analysis_clients
=
{}
...
@@ -14,17 +15,18 @@ analysis_clients = {}
...
@@ -14,17 +15,18 @@ analysis_clients = {}
@login_required
@login_required
def
init_corpus_analysis
(
corpus_id
):
def
init_corpus_analysis
(
corpus_id
):
'''
TODO: Check if current_user is allowed to subscribe to this
'''
'''
TODO: Check if current_user is allowed to subscribe to this
'''
if
str
(
corpus_id
)
not
in
analysis_sessions
:
analysis_sessions
[
str
(
corpus_id
)]
=
[
request
.
sid
]
socketio
.
start_background_task
(
observe_corpus_analysis_connection
,
socketio
.
start_background_task
(
observe_corpus_analysis_connection
,
current_app
.
_get_current_object
(),
current_app
.
_get_current_object
(),
corpus_id
,
corpus_id
,
request
.
sid
)
request
.
sid
)
@socketio.on
(
'
query_event
'
)
@socketio.on
(
'
query_event
'
)
def
recv_query
(
message
):
def
recv_query
(
message
):
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
logger
.
warning
(
message
)
logger
.
warning
(
message
)
analysis_client
=
analysis_clients
[
request
.
sid
]
#
analysis_client = analysis_clients[request.sid]
def
observe_corpus_analysis_connection
(
app
,
corpus_id
,
session_id
):
def
observe_corpus_analysis_connection
(
app
,
corpus_id
,
session_id
):
...
@@ -34,10 +36,11 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
...
@@ -34,10 +36,11 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
while
corpus
.
status
!=
'
analysing
'
:
while
corpus
.
status
!=
'
analysing
'
:
db
.
session
.
refresh
(
corpus
)
db
.
session
.
refresh
(
corpus
)
socketio
.
sleep
(
3
)
socketio
.
sleep
(
3
)
analysis_client
=
CQiWrapper
(
username
=
'
opaque
'
,
password
=
'
opaque
'
,
analysis_client
=
CQiWrapper
(
host
=
'
{}_analysis_container{}
'
.
format
(
corpus
.
creator
.
username
,
corpus
.
id
)
,
host
=
'
{}_analysis_container{}
'
.
format
(
corpus
.
creator
.
username
,
corpus
.
id
)
,
port
=
4877
)
password
=
'
opaque
'
,
port
=
4877
,
analysis_clients
[
session_id
]
=
analysis_client
username
=
'
opaque
'
)
analysis_client
.
connect
()
analysis_client
.
connect
()
analysis_clients
[
'
session_id
'
]
=
analysis_client
corpus_name
=
'
CORPUS
'
corpus_name
=
'
CORPUS
'
result_subcorpus_name
=
'
Query-results
'
# should be set by the user somehow
result_subcorpus_name
=
'
Query-results
'
# should be set by the user somehow
query
=
'"
and
"
;
'
query
=
'"
and
"
;
'
...
@@ -50,5 +53,8 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
...
@@ -50,5 +53,8 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
logger
.
warning
(
analysis_client
.
ctrl_ping
())
logger
.
warning
(
analysis_client
.
ctrl_ping
())
socketio
.
sleep
(
3
)
socketio
.
sleep
(
3
)
analysis_clients
.
pop
(
session_id
,
None
)
analysis_clients
.
pop
(
session_id
,
None
)
corpus
.
status
=
'
stop analysis
'
analysis_sessions
[
str
(
corpus_id
)].
remove
(
session_id
)
if
not
analysis_sessions
[
str
(
corpus_id
)]:
analysis_sessions
.
pop
(
str
(
corpus_id
),
None
)
corpus
.
status
=
'
stop analysis
'
db
.
session
.
commit
()
db
.
session
.
commit
()
This diff is collapsed.
Click to expand it.
app/corpora/views.py
+
3
−
2
View file @
8a607b6d
...
@@ -54,14 +54,15 @@ def corpus(corpus_id):
...
@@ -54,14 +54,15 @@ def corpus(corpus_id):
def
corpus_analysis
(
corpus_id
):
def
corpus_analysis
(
corpus_id
):
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
corpus
=
Corpus
.
query
.
get_or_404
(
corpus_id
)
corpus
=
Corpus
.
query
.
get_or_404
(
corpus_id
)
corpus
.
status
=
'
start analysis
'
if
corpus
.
status
==
'
prepared
'
:
corpus
.
status
=
'
start analysis
'
db
.
session
.
commit
()
query
=
request
.
args
.
get
(
'
query
'
)
query
=
request
.
args
.
get
(
'
query
'
)
logger
.
warning
(
'
Query first: {}
'
.
format
(
query
))
logger
.
warning
(
'
Query first: {}
'
.
format
(
query
))
hits_per_page
=
request
.
args
.
get
(
'
hits_per_page
'
,
30
)
hits_per_page
=
request
.
args
.
get
(
'
hits_per_page
'
,
30
)
context
=
request
.
args
.
get
(
'
context
'
,
10
)
context
=
request
.
args
.
get
(
'
context
'
,
10
)
dl_form
=
QueryDownloadForm
()
dl_form
=
QueryDownloadForm
()
form
=
QueryForm
(
hits_per_page
=
hits_per_page
,
context
=
context
,
query
=
query
)
form
=
QueryForm
(
hits_per_page
=
hits_per_page
,
context
=
context
,
query
=
query
)
db
.
session
.
commit
()
if
form
.
validate_on_submit
():
if
form
.
validate_on_submit
():
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
logger
.
warning
(
'
Data has been sent!
'
)
logger
.
warning
(
'
Data has been sent!
'
)
...
...
This diff is collapsed.
Click to expand it.
app/templates/corpora/corpus.html.j2
+
2
−
2
View file @
8a607b6d
...
@@ -62,9 +62,9 @@
...
@@ -62,9 +62,9 @@
statusElement.classList.add(CorpusList.STATUS_COLORS[status] || CorpusList.STATUS_COLORS['default']);
statusElement.classList.add(CorpusList.STATUS_COLORS[status] || CorpusList.STATUS_COLORS['default']);
statusElement.innerText = status;
statusElement.innerText = status;
var analyseBtn = document.getElementById('analyse');
var analyseBtn = document.getElementById('analyse');
if (status === 'prepared') {
if (status === 'prepared'
|| status === 'analysing'
) {
analyseBtn.classList.remove('hide', 'disabled');
analyseBtn.classList.remove('hide', 'disabled');
} else if (status ===
'analysing' || status ===
'start analysis' || status === 'stop analysis') {
} else if (status === 'start analysis' || status === 'stop analysis') {
analyseBtn.classList.remove('hide');
analyseBtn.classList.remove('hide');
analyseBtn.classList.add('disabled');
analyseBtn.classList.add('disabled');
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment