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
53b4b57b
Commit
53b4b57b
authored
4 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Add job restart url /jobs/job_id/restart
parent
43f79291
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
web/app/jobs/tasks.py
+22
-1
22 additions, 1 deletion
web/app/jobs/tasks.py
web/app/jobs/views.py
+18
-0
18 additions, 0 deletions
web/app/jobs/views.py
web/app/models.py
+12
-1
12 additions, 1 deletion
web/app/models.py
with
52 additions
and
2 deletions
web/app/jobs/tasks.py
+
22
−
1
View file @
53b4b57b
from
time
import
sleep
from
..
import
db
from
..
import
db
,
logger
from
..decorators
import
background
from
..models
import
Job
import
os
...
...
@@ -27,3 +27,24 @@ def delete_job(job_id, *args, **kwargs):
'
jobs
'
,
str
(
job
.
id
))
shutil
.
rmtree
(
path
,
ignore_errors
=
True
)
job
.
delete
()
@background
def
restart_job
(
job_id
,
*
args
,
**
kwargs
):
app
=
kwargs
[
'
app
'
]
with
app
.
app_context
():
job
=
Job
.
query
.
get
(
job_id
)
if
job
is
None
:
logger
.
warning
(
'
Job not found
'
)
return
if
job
.
status
!=
'
failed
'
:
logger
.
warning
(
'
Job not failed
'
)
return
logger
.
warning
(
'
Restarted
'
)
job_dir
=
os
.
path
.
join
(
app
.
config
[
'
NOPAQUE_STORAGE
'
],
str
(
job
.
user_id
),
'
jobs
'
,
str
(
job
.
id
))
shutil
.
rmtree
(
os
.
path
.
join
(
job_dir
,
'
output
'
),
ignore_errors
=
True
)
shutil
.
rmtree
(
os
.
path
.
join
(
job_dir
,
'
pyflow.data
'
),
ignore_errors
=
True
)
job
.
restart
()
This diff is collapsed.
Click to expand it.
web/app/jobs/views.py
+
18
−
0
View file @
53b4b57b
...
...
@@ -3,6 +3,7 @@ from flask import (abort, current_app, flash, redirect, render_template,
from
flask_login
import
current_user
,
login_required
from
.
import
jobs
from
.
import
tasks
from
..decorators
import
admin_required
from
..models
import
Job
,
JobInput
,
JobResult
import
os
...
...
@@ -49,6 +50,23 @@ def download_job_input(job_id, job_input_id):
filename
=
job_input
.
filename
)
@jobs.route
(
'
/<int:job_id>/restart
'
)
@login_required
@admin_required
def
restart
(
job_id
):
job
=
Job
.
query
.
get_or_404
(
job_id
)
if
job
.
status
!=
'
failed
'
:
flash
(
'
Job can not be restarted!
'
,
'
job
'
)
else
:
tasks
.
restart_job
(
job_id
)
flash
(
'
Job has been restarted!
'
,
'
job
'
)
job_inputs
=
[
dict
(
filename
=
input
.
filename
,
id
=
input
.
id
,
job_id
=
job
.
id
)
for
input
in
job
.
inputs
]
return
redirect
(
url_for
(
'
jobs.job
'
,
job_id
=
job_id
))
@jobs.route
(
'
/<int:job_id>/results/<int:job_result_id>/download
'
)
@login_required
def
download_job_result
(
job_id
,
job_result_id
):
...
...
This diff is collapsed.
Click to expand it.
web/app/models.py
+
12
−
1
View file @
53b4b57b
...
...
@@ -368,6 +368,17 @@ class Job(db.Model):
db
.
session
.
delete
(
self
)
db
.
session
.
commit
()
def
restart
(
self
):
'''
Restart a job - only if the status is failed
'''
if
self
.
status
!=
'
failed
'
:
return
self
.
end_date
=
None
self
.
status
=
'
submitted
'
db
.
session
.
commit
()
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
'
user_id
'
:
self
.
user_id
,
...
...
@@ -534,7 +545,7 @@ class Corpus(db.Model):
return
'
<Corpus {corpus_title}>
'
.
format
(
corpus_title
=
self
.
title
)
class
Result
(
db
.
Model
):
class
Result
(
db
.
Model
):
'''
Class to define a result set of one query.
'''
...
...
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