Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mutalyzer
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirrors
mutalyzer
Commits
63243903
Commit
63243903
authored
9 years ago
by
Vermaat
Browse files
Options
Downloads
Patches
Plain Diff
List batch jobs in admin interface
parent
217abd4a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mutalyzer/entrypoints/admin.py
+52
-1
52 additions, 1 deletion
mutalyzer/entrypoints/admin.py
with
52 additions
and
1 deletion
mutalyzer/entrypoints/admin.py
+
52
−
1
View file @
63243903
...
@@ -14,13 +14,14 @@ import os
...
@@ -14,13 +14,14 @@ import os
import
alembic.command
import
alembic.command
import
alembic.config
import
alembic.config
from
alembic.migration
import
MigrationContext
from
alembic.migration
import
MigrationContext
import
sqlalchemy
from
sqlalchemy.orm.exc
import
NoResultFound
from
sqlalchemy.orm.exc
import
NoResultFound
from
.
import
_cli_string
from
.
import
_cli_string
from
..
import
announce
from
..
import
announce
from
..
import
db
from
..
import
db
from
..db
import
session
from
..db
import
session
from
..db.models
import
Assembly
,
Chromosome
from
..db.models
import
Assembly
,
BatchJob
,
BatchQueueItem
,
Chromosome
from
..
import
mapping
from
..
import
mapping
from
..
import
output
from
..
import
output
from
..
import
sync
from
..
import
sync
...
@@ -151,6 +152,50 @@ def sync_cache(wsdl_url, url_template, history=7):
...
@@ -151,6 +152,50 @@ def sync_cache(wsdl_url, url_template, history=7):
%
(
inserted
,
downloaded
))
%
(
inserted
,
downloaded
))
def
list_batch_jobs
():
"""
List batch jobs.
"""
# For getting all batch jobs and their item counts, the following query
# might be more obvious at first thought. However, our current query below
# turns out to be more than twice as fast (and shorter).
#
# sq = session.query(
# BatchQueueItem.batch_job_id,
# sqlalchemy.func.count(BatchQueueItem.id).label('count')
# ).group_by(BatchQueueItem.batch_job_id).subquery()
# session.query(
# BatchJob,
# sq.c.count
# ).join(sq, BatchJob.id == sq.c.batch_job_id)
#
batch_jobs_with_counts
=
session
.
query
(
BatchJob
,
session
.
query
(
sqlalchemy
.
func
.
count
(
'
*
'
)).
filter
(
BatchQueueItem
.
batch_job_id
==
BatchJob
.
id
).
label
(
'
count
'
)
).
order_by
(
BatchJob
.
added
.
asc
()).
all
()
lengths
=
{
'
id_len
'
:
max
(
len
(
str
(
j
.
id
))
for
j
,
_
in
batch_jobs_with_counts
),
'
type_len
'
:
max
(
len
(
j
.
job_type
)
for
j
,
_
in
batch_jobs_with_counts
),
'
count_len
'
:
max
(
len
(
str
(
c
))
for
_
,
c
in
batch_jobs_with_counts
),
'
email_len
'
:
max
(
len
(
j
.
email
)
for
j
,
_
in
batch_jobs_with_counts
)
}
template
=
(
'
{id:{id_len}} {type:<{type_len}} {added:%Y-%m-%d %H:%M:%S}
'
'
{count:<{count_len}} {email:{email_len}}
'
)
for
batch_job
,
count
in
batch_jobs_with_counts
:
print
template
.
format
(
id
=
batch_job
.
id
,
type
=
batch_job
.
job_type
,
added
=
batch_job
.
added
,
count
=
count
,
email
=
batch_job
.
email
,
**
lengths
)
def
set_announcement
(
body
,
url
=
None
):
def
set_announcement
(
body
,
url
=
None
):
"""
"""
Set announcement to show to the user.
Set announcement to show to the user.
...
@@ -309,6 +354,12 @@ def main():
...
@@ -309,6 +354,12 @@ def main():
description
=
unset_announcement
.
__doc__
.
split
(
'
\n\n
'
)[
0
])
description
=
unset_announcement
.
__doc__
.
split
(
'
\n\n
'
)[
0
])
p
.
set_defaults
(
func
=
unset_announcement
)
p
.
set_defaults
(
func
=
unset_announcement
)
# Subparser 'batch-jobs'.
p
=
subparsers
.
add_parser
(
'
batch-jobs
'
,
help
=
'
list batch jobs
'
,
description
=
list_batch_jobs
.
__doc__
.
split
(
'
\n\n
'
)[
0
])
p
.
set_defaults
(
func
=
list_batch_jobs
)
# Subparser 'sync-cache'.
# Subparser 'sync-cache'.
p
=
subparsers
.
add_parser
(
p
=
subparsers
.
add_parser
(
'
sync-cache
'
,
help
=
'
synchronize cache with remote Mutalyzer
'
,
'
sync-cache
'
,
help
=
'
synchronize cache with remote Mutalyzer
'
,
...
...
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