Skip to content

Commit 514b78c

Browse files
committed
slurm2sql: sacct2: Add --running-at-time option
- Equivalent to --start=TIME --end=TIME --state=RUNNING, which will tell you what jobs have been running on a given node at a given time.
1 parent 5878c3c commit 514b78c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

slurm2sql.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,9 @@ def process_sacct_filter(args, sacct_filter):
10001000
# it shouldn't be re-handled in the future SQL code (future
10011001
# SQL woludn't handle multiple users, for example).
10021002
args.user = None
1003+
if getattr(args, 'running_at_time', None):
1004+
sacct_filter[:0] = [f'--start={args.running_at_time}', f'--end={args.running_at_time}', '--state=RUNNING' ]
1005+
args.running_at_time = None
10031006
return sacct_filter
10041007

10051008
def import_or_open_db(args, sacct_filter, csv_input=None):
@@ -1098,8 +1101,9 @@ def sacct_cli(argv=sys.argv[1:], csv_input=None):
10981101
parser.add_argument('--order',
10991102
help="SQL order by (arbitrary SQL expression using column names). NOT safe from SQL injection.")
11001103
parser.add_argument('--completed', '-c', action='store_true',
1101-
help=f"Select for completed job states ({COMPLETED_STATES}) You need to specify --starttime (-S) at some point in the past, due to how saccont default works (for example '-S now-1week'). This option automatically sets '-E now'")
1102-
parser.add_argument('--user', '-u', help="Limit to this or these users. This specific argument will work with --db, if it's a single user.")
1104+
help=f"Select for completed job states ({COMPLETED_STATES}) You need to specify --starttime (-S) at some point in the past, due to how saccont default works (for example '-S now-1week'). This option automatically sets '-E now'. Not compatible with --db.")
1105+
parser.add_argument('--user', '-u', help="Limit to this or these users. Compatible with --db.")
1106+
parser.add_argument('--running-at-time', metavar='TIME', help="Only jobs running at this time. Expanded to --start=TIME --end=TIME --state=R. Not compatible with --db.")
11031107
parser.add_argument('--csv-input',
11041108
help="Don't parse sacct but import this CSV file. It's read with "
11051109
"Python's default csv reader (excel format). Beware badly "

0 commit comments

Comments
 (0)