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
f86f3f4f
Commit
f86f3f4f
authored
4 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Move file deletion to model methods. add restart job button.
parent
e20a6a31
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
web/app/jobs/tasks.py
+2
-30
2 additions, 30 deletions
web/app/jobs/tasks.py
web/app/jobs/views.py
+1
-1
1 addition, 1 deletion
web/app/jobs/views.py
web/app/models.py
+25
-2
25 additions, 2 deletions
web/app/models.py
web/app/templates/jobs/job.html.j2
+4
-1
4 additions, 1 deletion
web/app/templates/jobs/job.html.j2
with
32 additions
and
34 deletions
web/app/jobs/tasks.py
+
2
−
30
View file @
f86f3f4f
from
time
import
sleep
from
..
import
db
,
logger
from
..decorators
import
background
from
..decorators
import
background
from
..models
import
Job
from
..models
import
Job
import
os
import
shutil
@background
@background
...
@@ -12,20 +8,7 @@ def delete_job(job_id, *args, **kwargs):
...
@@ -12,20 +8,7 @@ def delete_job(job_id, *args, **kwargs):
with
app
.
app_context
():
with
app
.
app_context
():
job
=
Job
.
query
.
get
(
job_id
)
job
=
Job
.
query
.
get
(
job_id
)
if
job
is
None
:
if
job
is
None
:
return
raise
Exception
(
'
Could not find job with id {}
'
.
format
(
job_id
))
if
job
.
status
not
in
[
'
complete
'
,
'
failed
'
]:
job
.
status
=
'
canceling
'
db
.
session
.
commit
()
while
job
.
status
!=
'
canceled
'
:
# In case the daemon handled a job in any way
if
job
.
status
!=
'
canceling
'
:
job
.
status
=
'
canceling
'
db
.
session
.
commit
()
sleep
(
1
)
db
.
session
.
refresh
(
job
)
path
=
os
.
path
.
join
(
app
.
config
[
'
NOPAQUE_STORAGE
'
],
str
(
job
.
user_id
),
'
jobs
'
,
str
(
job
.
id
))
shutil
.
rmtree
(
path
,
ignore_errors
=
True
)
job
.
delete
()
job
.
delete
()
...
@@ -35,16 +18,5 @@ def restart_job(job_id, *args, **kwargs):
...
@@ -35,16 +18,5 @@ def restart_job(job_id, *args, **kwargs):
with
app
.
app_context
():
with
app
.
app_context
():
job
=
Job
.
query
.
get
(
job_id
)
job
=
Job
.
query
.
get
(
job_id
)
if
job
is
None
:
if
job
is
None
:
logger
.
warning
(
'
Job not found
'
)
raise
Exception
(
'
Could not find job with id {}
'
.
format
(
job_id
))
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
()
job
.
restart
()
This diff is collapsed.
Click to expand it.
web/app/jobs/views.py
+
1
−
1
View file @
f86f3f4f
...
@@ -56,7 +56,7 @@ def download_job_input(job_id, job_input_id):
...
@@ -56,7 +56,7 @@ def download_job_input(job_id, job_input_id):
def
restart
(
job_id
):
def
restart
(
job_id
):
job
=
Job
.
query
.
get_or_404
(
job_id
)
job
=
Job
.
query
.
get_or_404
(
job_id
)
if
job
.
status
!=
'
failed
'
:
if
job
.
status
!=
'
failed
'
:
flash
(
'
Job can
not
be
restarted
!
'
,
'
job
'
)
flash
(
'
Could
not restart
job: status is not
"
fail
ed
"
'
,
'
error
'
)
else
:
else
:
tasks
.
restart_job
(
job_id
)
tasks
.
restart_job
(
job_id
)
flash
(
'
Job has been restarted!
'
,
'
job
'
)
flash
(
'
Job has been restarted!
'
,
'
job
'
)
...
...
This diff is collapsed.
Click to expand it.
web/app/models.py
+
25
−
2
View file @
f86f3f4f
...
@@ -2,9 +2,12 @@ from datetime import datetime
...
@@ -2,9 +2,12 @@ from datetime import datetime
from
flask
import
current_app
from
flask
import
current_app
from
flask_login
import
UserMixin
,
AnonymousUserMixin
from
flask_login
import
UserMixin
,
AnonymousUserMixin
from
itsdangerous
import
BadSignature
,
TimedJSONWebSignatureSerializer
from
itsdangerous
import
BadSignature
,
TimedJSONWebSignatureSerializer
from
time
import
sleep
from
werkzeug.security
import
generate_password_hash
,
check_password_hash
from
werkzeug.security
import
generate_password_hash
,
check_password_hash
from
werkzeug.utils
import
secure_filename
from
werkzeug.utils
import
secure_filename
from
.
import
db
,
login_manager
from
.
import
db
,
login_manager
import
os
import
shutil
class
Permission
:
class
Permission
:
...
@@ -364,7 +367,21 @@ class Job(db.Model):
...
@@ -364,7 +367,21 @@ class Job(db.Model):
'''
'''
Delete the job and its inputs and results from the database.
Delete the job and its inputs and results from the database.
'''
'''
if
self
.
status
not
in
[
'
complete
'
,
'
failed
'
]:
self
.
status
=
'
canceling
'
db
.
session
.
commit
()
while
self
.
status
!=
'
canceled
'
:
# In case the daemon handled a job in any way
if
self
.
status
!=
'
canceling
'
:
self
.
status
=
'
canceling
'
db
.
session
.
commit
()
sleep
(
1
)
db
.
session
.
refresh
(
self
)
job_dir
=
os
.
path
.
join
(
current_app
.
config
[
'
NOPAQUE_STORAGE
'
],
str
(
self
.
user_id
),
'
jobs
'
,
str
(
self
.
id
))
shutil
.
rmtree
(
job_dir
,
ignore_errors
=
True
)
db
.
session
.
delete
(
self
)
db
.
session
.
delete
(
self
)
db
.
session
.
commit
()
db
.
session
.
commit
()
...
@@ -374,7 +391,13 @@ class Job(db.Model):
...
@@ -374,7 +391,13 @@ class Job(db.Model):
'''
'''
if
self
.
status
!=
'
failed
'
:
if
self
.
status
!=
'
failed
'
:
return
raise
Exception
(
'
Could not restart job: status is not
"
failed
"'
)
job_dir
=
os
.
path
.
join
(
current_app
.
config
[
'
NOPAQUE_STORAGE
'
],
str
(
self
.
user_id
),
'
jobs
'
,
str
(
self
.
id
))
shutil
.
rmtree
(
os
.
path
.
join
(
job_dir
,
'
output
'
),
ignore_errors
=
True
)
shutil
.
rmtree
(
os
.
path
.
join
(
job_dir
,
'
pyflow.data
'
),
ignore_errors
=
True
)
self
.
end_date
=
None
self
.
end_date
=
None
self
.
status
=
'
submitted
'
self
.
status
=
'
submitted
'
db
.
session
.
commit
()
db
.
session
.
commit
()
...
...
This diff is collapsed.
Click to expand it.
web/app/templates/jobs/job.html.j2
+
4
−
1
View file @
f86f3f4f
...
@@ -71,7 +71,10 @@
...
@@ -71,7 +71,10 @@
</div>
</div>
</div>
</div>
<div class="card-action right-align">
<div class="card-action right-align">
<a href="#" class="btn disabled waves-effect waves-light"><i class="material-icons left">settings</i>Export Parameters</a>
{% if current_user.is_administrator() and job.status == 'failed' %}
<a href="{{ url_for('jobs.restart', job_id=job.id) }}" class="btn waves-effect waves-light"><i class="material-icons left">repeat</i>Restart</a>
{% endif %}
<!-- <a href="#" class="btn disabled waves-effect waves-light"><i class="material-icons left">settings</i>Export Parameters</a> -->
<a data-target="delete-job-modal" class="waves-effect waves-light btn red modal-trigger"><i class="material-icons left">delete</i>Delete</a>
<a data-target="delete-job-modal" class="waves-effect waves-light btn red modal-trigger"><i class="material-icons left">delete</i>Delete</a>
</div>
</div>
</div>
</div>
...
...
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