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
07103ee4
Commit
07103ee4
authored
1 year ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Fix issues in cqi_over_sio
parent
efa8712c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/corpora/cqi_over_sio/__init__.py
+10
-7
10 additions, 7 deletions
app/corpora/cqi_over_sio/__init__.py
app/corpora/cqi_over_sio/cqi.py
+15
-12
15 additions, 12 deletions
app/corpora/cqi_over_sio/cqi.py
app/static/js/cqi/models/corpora.js
+3
-3
3 additions, 3 deletions
app/static/js/cqi/models/corpora.js
with
28 additions
and
22 deletions
app/corpora/cqi_over_sio/__init__.py
+
10
−
7
View file @
07103ee4
...
@@ -84,7 +84,7 @@ def connect(auth):
...
@@ -84,7 +84,7 @@ def connect(auth):
retry_counter
-=
1
retry_counter
-=
1
db
.
session
.
refresh
(
corpus
)
db
.
session
.
refresh
(
corpus
)
cqi_client
=
CQiClient
(
f
'
cqpserver_
{
corpus_id
}
'
)
cqi_client
=
CQiClient
(
f
'
cqpserver_
{
corpus_id
}
'
)
session
[
'
d
'
]
=
{
session
[
'
cqi_over_sio
'
]
=
{
'
corpus_id
'
:
corpus_id
,
'
corpus_id
'
:
corpus_id
,
'
cqi_client
'
:
cqi_client
,
'
cqi_client
'
:
cqi_client
,
'
cqi_client_lock
'
:
Lock
(),
'
cqi_client_lock
'
:
Lock
(),
...
@@ -94,16 +94,19 @@ def connect(auth):
...
@@ -94,16 +94,19 @@ def connect(auth):
@socketio.on
(
'
disconnect
'
,
namespace
=
NAMESPACE
)
@socketio.on
(
'
disconnect
'
,
namespace
=
NAMESPACE
)
def
disconnect
():
def
disconnect
():
if
'
d
'
not
in
session
:
try
:
cqi_client
:
CQiClient
=
session
[
'
cqi_over_sio
'
][
'
cqi_client
'
]
cqi_client_lock
:
Lock
=
session
[
'
cqi_over_sio
'
][
'
cqi_client_lock
'
]
except
KeyError
:
return
return
session
[
'
d
'
][
'
cqi_client_lock
'
]
.
acquire
()
cqi_client_lock
.
acquire
()
try
:
try
:
session
[
'
d
'
][
'
cqi_client
'
]
.
api
.
ctrl_bye
()
cqi_client
.
api
.
ctrl_bye
()
except
(
BrokenPipeError
,
CQiException
):
except
(
BrokenPipeError
,
CQiException
):
pass
pass
session
[
'
d
'
][
'
cqi_client_lock
'
]
.
release
()
cqi_client_lock
.
release
()
corpus
=
Corpus
.
query
.
get
(
session
[
'
d
'
][
'
corpus_id
'
])
corpus
=
Corpus
.
query
.
get
(
session
[
'
cqi_over_sio
'
][
'
corpus_id
'
])
corpus
.
num_analysis_sessions
=
Corpus
.
num_analysis_sessions
-
1
corpus
.
num_analysis_sessions
=
Corpus
.
num_analysis_sessions
-
1
db
.
session
.
commit
()
db
.
session
.
commit
()
session
.
pop
(
'
d
'
)
session
.
pop
(
'
cqi_over_sio
'
)
# return {'code': 200, 'msg': 'OK'}
# return {'code': 200, 'msg': 'OK'}
This diff is collapsed.
Click to expand it.
app/corpora/cqi_over_sio/cqi.py
+
15
−
12
View file @
07103ee4
from
cqi
import
API
Client
from
cqi
import
CQi
Client
from
cqi.errors
import
CQiException
from
cqi.errors
import
CQiException
from
cqi.status
import
CQiStatus
from
cqi.status
import
CQiStatus
from
flask
import
session
from
flask
import
session
from
inspect
import
signature
from
inspect
import
signature
from
threading
import
Lock
from
typing
import
Callable
,
Dict
,
List
from
typing
import
Callable
,
Dict
,
List
from
app
import
socketio
from
app
import
socketio
from
app.decorators
import
socketio_login_required
from
app.decorators
import
socketio_login_required
...
@@ -60,18 +61,20 @@ CQI_API_FUNCTIONS: List[str] = [
...
@@ -60,18 +61,20 @@ CQI_API_FUNCTIONS: List[str] = [
@socketio.on
(
'
cqi_client.api
'
,
namespace
=
ns
)
@socketio.on
(
'
cqi_client.api
'
,
namespace
=
ns
)
@socketio_login_required
@socketio_login_required
def
cqi_over_sio
(
fn_data
):
def
cqi_over_sio
(
fn_data
):
try
:
fn_name
:
str
=
fn_data
[
'
fn_name
'
]
if
fn_name
not
in
CQI_API_FUNCTIONS
:
raise
KeyError
except
KeyError
:
return
{
'
code
'
:
400
,
'
msg
'
:
'
Bad Request
'
}
fn_name
:
str
=
fn_data
[
'
fn_name
'
]
fn_name
:
str
=
fn_data
[
'
fn_name
'
]
fn_args
:
Dict
=
fn_data
.
get
(
'
fn_args
'
,
{})
fn_args
:
Dict
=
fn_data
.
get
(
'
fn_args
'
,
{})
print
(
f
'
{
fn_name
}
(
{
fn_args
}
)
'
)
if
'
d
'
not
in
session
:
return
{
'
code
'
:
424
,
'
msg
'
:
'
Failed Dependency
'
}
api_client
:
APIClient
=
session
[
'
d
'
][
'
cqi_client
'
].
api
if
fn_name
not
in
CQI_API_FUNCTIONS
:
return
{
'
code
'
:
400
,
'
msg
'
:
'
Bad Request
'
}
try
:
try
:
fn
:
Callable
=
getattr
(
api_client
,
fn_name
)
cqi_client
:
CQiClient
=
session
[
'
cqi_over_sio
'
][
'
cqi_client
'
]
except
AttributeError
:
cqi_client_lock
:
Lock
=
session
[
'
cqi_over_sio
'
][
'
cqi_client_lock
'
]
return
{
'
code
'
:
400
,
'
msg
'
:
'
Bad Request
'
}
except
KeyError
:
return
{
'
code
'
:
424
,
'
msg
'
:
'
Failed Dependency
'
}
fn
:
Callable
=
getattr
(
cqi_client
.
api
,
fn_name
)
for
param
in
signature
(
fn
).
parameters
.
values
():
for
param
in
signature
(
fn
).
parameters
.
values
():
if
param
.
default
is
param
.
empty
:
if
param
.
default
is
param
.
empty
:
if
param
.
name
not
in
fn_args
:
if
param
.
name
not
in
fn_args
:
...
@@ -81,7 +84,7 @@ def cqi_over_sio(fn_data):
...
@@ -81,7 +84,7 @@ def cqi_over_sio(fn_data):
continue
continue
if
type
(
fn_args
[
param
.
name
])
is
not
param
.
annotation
:
if
type
(
fn_args
[
param
.
name
])
is
not
param
.
annotation
:
return
{
'
code
'
:
400
,
'
msg
'
:
'
Bad Request
'
}
return
{
'
code
'
:
400
,
'
msg
'
:
'
Bad Request
'
}
session
[
'
d
'
][
'
cqi_client_lock
'
]
.
acquire
()
cqi_client_lock
.
acquire
()
try
:
try
:
return_value
=
fn
(
**
fn_args
)
return_value
=
fn
(
**
fn_args
)
except
BrokenPipeError
:
except
BrokenPipeError
:
...
@@ -100,7 +103,7 @@ def cqi_over_sio(fn_data):
...
@@ -100,7 +103,7 @@ def cqi_over_sio(fn_data):
}
}
}
}
finally
:
finally
:
session
[
'
d
'
][
'
cqi_client_lock
'
]
.
release
()
cqi_client_lock
.
release
()
if
isinstance
(
return_value
,
CQiStatus
):
if
isinstance
(
return_value
,
CQiStatus
):
payload
=
{
payload
=
{
'
code
'
:
return_value
.
code
,
'
code
'
:
return_value
.
code
,
...
...
This diff is collapsed.
Click to expand it.
app/static/js/cqi/models/corpora.js
+
3
−
3
View file @
07103ee4
...
@@ -40,21 +40,21 @@ cqi.models.corpora.Corpus = class Corpus extends cqi.models.resource.Model {
...
@@ -40,21 +40,21 @@ cqi.models.corpora.Corpus = class Corpus extends cqi.models.resource.Model {
/**
/**
* @returns {cqi.models.attributes.AlignmentAttributeCollection}
* @returns {cqi.models.attributes.AlignmentAttributeCollection}
*/
*/
get
alignment
_a
ttributes
()
{
get
alignment
A
ttributes
()
{
return
new
cqi
.
models
.
attributes
.
AlignmentAttributeCollection
(
this
.
client
,
this
);
return
new
cqi
.
models
.
attributes
.
AlignmentAttributeCollection
(
this
.
client
,
this
);
}
}
/**
/**
* @returns {cqi.models.attributes.PositionalAttributeCollection}
* @returns {cqi.models.attributes.PositionalAttributeCollection}
*/
*/
get
positional
_a
ttributes
()
{
get
positional
A
ttributes
()
{
return
new
cqi
.
models
.
attributes
.
PositionalAttributeCollection
(
this
.
client
,
this
);
return
new
cqi
.
models
.
attributes
.
PositionalAttributeCollection
(
this
.
client
,
this
);
}
}
/**
/**
* @returns {cqi.models.attributes.StructuralAttributeCollection}
* @returns {cqi.models.attributes.StructuralAttributeCollection}
*/
*/
get
structural
_a
ttributes
()
{
get
structural
A
ttributes
()
{
return
new
cqi
.
models
.
attributes
.
StructuralAttributeCollection
(
this
.
client
,
this
);
return
new
cqi
.
models
.
attributes
.
StructuralAttributeCollection
(
this
.
client
,
this
);
}
}
...
...
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