Skip to content

Commit a456d69

Browse files
committed
slurm2sql: seff2 gets --long option that includes Start/End
1 parent 7870864 commit a456d69

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

slurm2sql.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,8 @@ def seff_cli(argv=sys.argv[1:], csv_input=None):
11951195
help="Aggregate data by user.")
11961196
parser.add_argument('--order',
11971197
help="SQL order by (arbitrary SQL expression using column names). NOT safe from SQL injection.")
1198+
parser.add_argument('--long', '-l', action='store_true',
1199+
help="Longer output format that includes job start/end times.")
11981200
parser.add_argument('--csv-input',
11991201
help="Don't parse sacct but import this CSV file. It's read with "
12001202
"Python's default csv reader (excel format). Beware badly "
@@ -1226,6 +1228,10 @@ def seff_cli(argv=sys.argv[1:], csv_input=None):
12261228
else:
12271229
order_by = ''
12281230

1231+
long_output = ''
1232+
if args.long:
1233+
long_output = "strftime('%Y-%m-%d %H:%M', Start, 'unixepoch') AS Start, strftime('%Y-%m-%d %H:%M', End, 'unixepoch') AS End,"
1234+
12291235
db = import_or_open_db(args, sacct_filter, csv_input=csv_input)
12301236

12311237
# If we run sacct, then args.user is set to None so we don't do double filtering here
@@ -1266,6 +1272,7 @@ def seff_cli(argv=sys.argv[1:], csv_input=None):
12661272
JobID,
12671273
User,
12681274
round(Elapsed/3600,2) AS hours,
1275+
{long_output}
12691276
12701277
NCPUS,
12711278
printf("%3.0f%%",round(CPUeff, 2)*100) AS "CPUeff",
@@ -1289,7 +1296,8 @@ def seff_cli(argv=sys.argv[1:], csv_input=None):
12891296
print("No data fetched with these sacct options.")
12901297
exit(2)
12911298
print(tabulate(data, headers=headers, tablefmt=args.format,
1292-
colalign=('decimal', 'left', 'decimal',
1299+
colalign=('decimal', 'center', 'decimal',
1300+
*(['center', 'center'] if long_output else []),
12931301
'decimal', 'right', # cpu
12941302
'decimal', 'decimal', 'right', # mem
12951303
'decimal', 'right', # gpu

0 commit comments

Comments
 (0)