From 5ddccdde6f7782a189c5db0730150cfda29956f7 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Mon, 1 Apr 2024 11:06:26 -0500 Subject: [PATCH] Add option for displaying usernames or emails in query jobs-nonterminal --- parts/22-query.sh | 54 +++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/parts/22-query.sh b/parts/22-query.sh index 286991f..ed81a9e 100644 --- a/parts/22-query.sh +++ b/parts/22-query.sh @@ -571,13 +571,13 @@ query_runtime-per-user() { ##? : computation time of user (by email) EOF } -query_jobs-nonterminal() { ## [--states=new,queued,running] [--update-time] [--older-than=] [username|id|email]: Job info of nonterminal jobs separated by user +query_jobs-nonterminal() { ## [--states=new,queued,running] [--update-time] [--older-than=] [--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 @@ -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, @@ -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 @@ -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