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
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
1092312e
Commit
1092312e
authored
5 years ago
by
Stephan Porada
Browse files
Options
Downloads
Patches
Plain Diff
Add NLP view.
parent
ab688e29
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/services/forms.py
+2
-2
2 additions, 2 deletions
app/services/forms.py
app/services/views.py
+51
-1
51 additions, 1 deletion
app/services/views.py
with
53 additions
and
3 deletions
app/services/forms.py
+
2
−
2
View file @
1092312e
...
...
@@ -24,7 +24,7 @@ class NewOCRJobForm(FlaskForm):
],
validators
=
[
DataRequired
()]
)
submit
=
SubmitField
(
'
Create OCR job
'
)
submit
=
SubmitField
(
'
Submit
'
)
title
=
StringField
(
'
Title
'
,
validators
=
[
DataRequired
(),
Length
(
1
,
32
)]
...
...
@@ -64,7 +64,7 @@ class NewNLPJobForm(FlaskForm):
],
validators
=
[
DataRequired
()]
)
submit
=
SubmitField
(
'
Create OCR job
'
)
submit
=
SubmitField
(
'
Submit
'
)
title
=
StringField
(
'
Title
'
,
validators
=
[
DataRequired
(),
Length
(
1
,
32
)]
...
...
This diff is collapsed.
Click to expand it.
app/services/views.py
+
51
−
1
View file @
1092312e
...
...
@@ -2,7 +2,7 @@ from datetime import datetime
from
flask
import
current_app
,
flash
,
redirect
,
render_template
,
url_for
from
.
import
services
from
flask_login
import
current_user
,
login_required
from
.forms
import
NewOCRJobForm
from
.forms
import
NewOCRJobForm
,
NewNLPJobForm
from
..
import
swarm
from
threading
import
Thread
import
hashlib
...
...
@@ -57,3 +57,53 @@ def ocr():
title
=
'
Optical Character Recognition
'
,
new_ocr_job_form
=
new_ocr_job_form
)
@services.route
(
'
/nlp
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@login_required
def
nlp
():
new_nlp_job_form
=
NewNLPJobForm
()
if
new_nlp_job_form
.
validate_on_submit
():
app
=
current_app
.
_get_current_object
()
id
=
hashlib
.
md5
(
(
current_user
.
username
+
'
_
'
+
datetime
.
now
().
isoformat
()).
encode
()
).
hexdigest
()
'''
'
TODO: Implement a Job class. For now a dictionary representation
'
is enough.
'''
job
=
{
'
creator
'
:
current_user
.
id
,
'
id
'
:
id
,
'
requested_cpus
'
:
2
,
'
requested_memory
'
:
2048
,
'
service
'
:
'
nlp
'
,
'
service_args
'
:
{
'
lang
'
:
new_nlp_job_form
.
language
.
data
,
'
version
'
:
new_nlp_job_form
.
version
.
data
},
'
status
'
:
'
queued
'
}
dir
=
os
.
path
.
join
(
app
.
config
[
'
OPAQUE_STORAGE
'
],
'
jobs
'
,
id
)
try
:
os
.
makedirs
(
dir
)
except
OSError
:
flash
(
'
OSError!
'
)
else
:
for
file
in
new_nlp_job_form
.
files
.
data
:
file
.
save
(
os
.
path
.
join
(
dir
,
file
.
filename
))
'''
'
TODO: Let the scheduler run this job in the background.
'
'
NOTE: Using self created threads is just for testing purpose as
'
there is no scheduler available.
'''
thread
=
Thread
(
target
=
swarm
.
run
,
args
=
(
job
,))
thread
.
start
()
flash
(
'
Job created!
'
)
return
redirect
(
url_for
(
'
services.nlp
'
))
return
render_template
(
'
services/nlp.html.j2
'
,
title
=
'
Natrual Language Processing
'
,
new_nlp_job_form
=
new_nlp_job_form
)
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