-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix issue with git clone preventing jobs from running
- Loading branch information
Showing
5 changed files
with
86 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,62 @@ | ||
from django.contrib import admin | ||
from .models import Job, CommandLineToolJob | ||
from .models import Job, CommandLineToolJob, Status | ||
from toil_orchestrator.tasks import cleanup_folders | ||
from django.contrib import messages | ||
|
||
|
||
class StatusFilter(admin.SimpleListFilter): | ||
title = 'Status' | ||
parameter_name = 'status' | ||
|
||
def lookups(self, request, model_admin): | ||
filters = {k:v for (k, v) in request.GET.items() if "range" not in k and "status" not in k | ||
and "q" not in k and "p" not in k} | ||
|
||
qs = model_admin.get_queryset(request).filter(**filters) | ||
return [(status.value, "%s (%s)" % (status.name, qs.filter(status=status.value).count())) for status in Status] | ||
|
||
def queryset(self, request, queryset): | ||
if self.value(): | ||
return queryset.filter(status=self.value()) | ||
return queryset | ||
|
||
|
||
@admin.register(Job) | ||
class JobAdmin(admin.ModelAdmin): | ||
actions = ['cleanup_files'] | ||
report_message = """ | ||
Cleaning up {cleaning} job(s) [{partial_cleaning} partial] | ||
Already cleaned up {cleaned_up} | ||
""" | ||
list_display = ("id", "status", "created_date", "modified_date", "external_id") | ||
ordering = ('-created_date',) | ||
list_filter = (StatusFilter,) | ||
|
||
def cleanup_files(self, request, queryset): | ||
cleaned_up_projects = 0 | ||
partially_cleaned_up_projects = 0 | ||
already_cleaned_up_projects = 0 | ||
for job in queryset: | ||
actions = ['cleanup_files'] | ||
|
||
if all([job.job_store_clean_up, job.working_dir_clean_up]): | ||
cleaned_up_projects = cleaned_up_projects + 1 | ||
elif any([job.job_store_clean_up, job.working_dir_clean_up]): | ||
cleaned_up_projects = cleaned_up_projects + 1 | ||
partially_cleaned_up_projects = partially_cleaned_up_projects + 1 | ||
else: | ||
already_cleaned_up_projects = already_cleaned_up_projects + 1 | ||
def cleanup_files(self, request, queryset): | ||
cleaned_up_projects = 0 | ||
partially_cleaned_up_projects = 0 | ||
already_cleaned_up_projects = 0 | ||
report_message = """ | ||
Cleaning up {cleaning} job(s) [{partial_cleaning} partial] | ||
Already cleaned up {cleaned_up} | ||
""" | ||
for job in queryset: | ||
|
||
cleanup_folders.delay(str(job.id)) | ||
if all([job.job_store_clean_up, job.working_dir_clean_up]): | ||
cleaned_up_projects = cleaned_up_projects + 1 | ||
elif any([job.job_store_clean_up, job.working_dir_clean_up]): | ||
cleaned_up_projects = cleaned_up_projects + 1 | ||
partially_cleaned_up_projects = partially_cleaned_up_projects + 1 | ||
else: | ||
already_cleaned_up_projects = already_cleaned_up_projects + 1 | ||
|
||
message = self.report_message.format(cleaning=cleaned_up_projects, | ||
partial_cleaning=partially_cleaned_up_projects, | ||
cleaned_up=already_cleaned_up_projects) | ||
cleanup_folders.delay(str(job.id)) | ||
|
||
self.message_user(request, message, level=messages.WARNING) | ||
message = report_message.format(cleaning=cleaned_up_projects, | ||
partial_cleaning=partially_cleaned_up_projects, | ||
cleaned_up=already_cleaned_up_projects) | ||
|
||
cleanup_files.short_description = "Cleanup up the TOIL jobstore and workdir" | ||
list_display = ("id", "status", "created_date", "modified_date", "external_id") | ||
ordering = ('-created_date',) | ||
self.message_user(request, message, level=messages.WARNING) | ||
|
||
cleanup_files.short_description = "Cleanup up the TOIL jobstore and workdir" | ||
|
||
@admin.register(CommandLineToolJob) | ||
class CommandLineToolJobAdmin(admin.ModelAdmin): | ||
list_display = ("id", "job_name", "status", "created_date", "modified_date", "started", "submitted", "finished") | ||
list_display = ("id", "job_name", "status", "created_date", "modified_date", "started", "submitted", "finished") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters