Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for displaying usernames or emails in query jobs-nonterminal #151

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 34 additions & 20 deletions parts/22-query.sh
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,13 @@ query_runtime-per-user() { ##? <email>: computation time of user (by email)
EOF
}

query_jobs-nonterminal() { ## [--states=new,queued,running] [--update-time] [--older-than=<interval>] [username|id|email]: Job info of nonterminal jobs separated by user
query_jobs-nonterminal() { ## [--states=new,queued,running] [--update-time] [--older-than=<interval>] [--show-user=id|email|username] [username|id|email]: Job info of nonterminal jobs separated by user
handle_help "$@" <<-EOF
You can request the user information by username, id, and user email

$ gxadmin query jobs-nonterminal helena-Rasche
id | tool_id | state | create_time | runner | ext_id | handler | user_id
---------+---------------------+---------+----------------------------+--------+--------+-----------------+---------
id | tool_id | state | create_time | runner | ext_id | handler | user
---------+---------------------+---------+----------------------------+--------+--------+-----------------+------
4760549 | featurecounts/1.6.3 | running | 2019-01-18 14:05:14.871711 | condor | 197549 | handler_main_7 | 599
4760552 | featurecounts/1.6.3 | running | 2019-01-18 14:05:16.205867 | condor | 197552 | handler_main_7 | 599
4760554 | featurecounts/1.6.3 | running | 2019-01-18 14:05:17.170157 | condor | 197580 | handler_main_8 | 599
Expand All @@ -591,16 +591,25 @@ query_jobs-nonterminal() { ## [--states=new,queued,running] [--update-time] [--o
You can also query all non-terminal jobs by all users

$ gxadmin query jobs-nonterminal | head
id | tool_id | state | create_time | runner | ext_id | handler | user_id
---------+---------------------+---------+----------------------------+--------+--------+-----------------+---------
4760549 | featurecounts/1.6.3 | running | 2019-01-18 14:05:14.871711 | condor | 197549 | handler_main_7 | 599
4760552 | featurecounts/1.6.3 | running | 2019-01-18 14:05:16.205867 | condor | 197552 | handler_main_7 | 599
4760554 | featurecounts/1.6.3 | running | 2019-01-18 14:05:17.170157 | condor | 197580 | handler_main_8 | 599
4760557 | featurecounts/1.6.3 | running | 2019-01-18 14:05:18.25044 | condor | 197545 | handler_main_10 | 599
4760573 | featurecounts/1.6.3 | running | 2019-01-18 14:05:47.20392 | condor | 197553 | handler_main_2 | 599
4760588 | featurecounts/1.6.3 | new | 2019-01-18 14:11:03.766558 | | | handler_main_9 | 11
4760589 | featurecounts/1.6.3 | new | 2019-01-18 14:11:05.895232 | | | handler_main_1 | 11
4760590 | featurecounts/1.6.3 | new | 2019-01-18 14:11:07.328533 | | | handler_main_2 | 11
id | tool_id | state | create_time | runner | ext_id | handler | user
---------+---------------------+---------+----------------------------+--------+--------+-----------------+------
4760549 | featurecounts/1.6.3 | running | 2019-01-18 14:05:14.871711 | condor | 197549 | handler_main_7 | 599
4760552 | featurecounts/1.6.3 | running | 2019-01-18 14:05:16.205867 | condor | 197552 | handler_main_7 | 599
4760554 | featurecounts/1.6.3 | running | 2019-01-18 14:05:17.170157 | condor | 197580 | handler_main_8 | 599
4760557 | featurecounts/1.6.3 | running | 2019-01-18 14:05:18.25044 | condor | 197545 | handler_main_10 | 599
4760573 | featurecounts/1.6.3 | running | 2019-01-18 14:05:47.20392 | condor | 197553 | handler_main_2 | 599
4760588 | featurecounts/1.6.3 | new | 2019-01-18 14:11:03.766558 | | | handler_main_9 | 11
4760589 | featurecounts/1.6.3 | new | 2019-01-18 14:11:05.895232 | | | handler_main_1 | 11
4760590 | featurecounts/1.6.3 | new | 2019-01-18 14:11:07.328533 | | | handler_main_2 | 11

You can display user emails or usernames rather than user ID using the --show-user option:

$ gxadmin query jobs-nonterminal --show-user=username
id | tool_id | state | create_time | runner | ext_id | handler | user
--------+----------------------+---------+---------------------+--------+--------+-----------+----------
897234 | hisat2/2.1.0+galaxy7 | running | 2021-05-25 04:13:19 | slurm | 987443 | handler_1 | zaphod
897798 | hisat2/2.1.0+galaxy7 | queued | 2021-05-25 08:20:12 | slurm | 988014 | handler_0 | ford
899127 | hisat2/2.1.0+galaxy7 | new | 2021-05-25 09:43:44 | slurm | 990129 | handler_2 | trillian

By default jobs in the states 'new', 'queued', and 'running' are considered non-terminal, but this can
be controlled by passing a comma-separated list to the '--states=' parameter. In addition, by default,
Expand All @@ -614,22 +623,27 @@ query_jobs-nonterminal() { ## [--states=new,queued,running] [--update-time] [--o
days:

$ gxadmin query jobs-nonterminal --states=queued,running --older-than='2 days' --update-time | head -5
id | tool_id | state | update_time | runner | ext_id | handler | user_id
--------+----------------------+---------+---------------------+--------------+--------+------------------+---------
335897 | trinity/2.9.1 | queued | 2021-03-10 10:44:09 | bridges | 335897 | main_w3_handler2 | 599
338554 | repeatmasker/4.0.9 | running | 2021-03-09 10:41:30 | jetstream_iu | 338554 | main_w4_handler2 | 11
338699 | hisat2/2.1.0+galaxy7 | queued | 2021-03-10 05:36:26 | jetstream_iu | 338699 | main_w3_handler2 | 42
id | tool_id | state | update_time | runner | ext_id | handler | user
--------+----------------------+---------+---------------------+--------------+--------+------------------+------
335897 | trinity/2.9.1 | queued | 2021-03-10 10:44:09 | bridges | 335897 | main_w3_handler2 | 599
338554 | repeatmasker/4.0.9 | running | 2021-03-09 10:41:30 | jetstream_iu | 338554 | main_w4_handler2 | 11
338699 | hisat2/2.1.0+galaxy7 | queued | 2021-03-10 05:36:26 | jetstream_iu | 338699 | main_w3_handler2 | 42
EOF

states='new,queued,running'
interval=
user_filter='true'
time_column='create_time'
user_column='job.user_id'

if (( $# > 0 )); then
for args in "$@"; do
if [[ "$args" = '--update-time' ]]; then
time_column='update_time'
elif [[ "$args" = '--show-user=email' ]]; then
user_column='galaxy_user.email'
elif [[ "$args" = '--show-user=username' ]]; then
user_column='galaxy_user.username'
elif [[ "${args:0:9}" = '--states=' ]]; then
states="${args:9}"
elif [[ "${args:0:13}" = '--older-than=' ]]; then
Expand All @@ -646,11 +660,11 @@ query_jobs-nonterminal() { ## [--states=new,queued,running] [--update-time] [--o
interval="AND job.$time_column < NOW() - interval '$interval'"
fi

user_id=$(gdpr_safe job.user_id user_id "anon")
user=$(gdpr_safe "$user_column" user "anon")

read -r -d '' QUERY <<-EOF
SELECT
job.id, job.tool_id, job.state, job.$time_column AT TIME ZONE 'UTC' AS $time_column, job.job_runner_name, job.job_runner_external_id, job.handler, $user_id
job.id, job.tool_id, job.state, job.$time_column AT TIME ZONE 'UTC' AS $time_column, job.job_runner_name, job.job_runner_external_id, job.handler, $user
FROM
job
LEFT OUTER JOIN
Expand Down
Loading