Skip to content

Commit 8dd170a

Browse files
committed
flux-jobs: support constraint query string with -f, --filter
Problem: There is no way to provide an arbitrary constraint to flux-jobs(1). Update the `-f, --filter` option of flux-jobs(1) to take a query string that will be passed to the JobList constraint parameter instead of the filter paramter.
1 parent edff7c1 commit 8dd170a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/cmd/flux-jobs.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from flux.job.stats import JobStats
2222
from flux.util import (
2323
FilterAction,
24-
FilterActionSetUpdate,
24+
FilterActionConcatenate,
2525
FilterTrueAction,
2626
UtilConfig,
2727
help_formatter,
@@ -151,21 +151,21 @@ def fetch_jobs_flux(args, fields, flux_handle=None):
151151
if args.filter:
152152
LOGGER.warning("Both -a and --filter specified, ignoring -a")
153153
else:
154-
args.filter.update(["pending", "running", "inactive"])
154+
args.filter = "pending,running,inactive"
155155

156156
if not args.filter:
157-
args.filter = {"pending", "running"}
157+
args.filter = "pending,running"
158158

159159
jobs_rpc = JobList(
160160
flux_handle,
161161
ids=args.jobids,
162162
attrs=attrs,
163-
filters=args.filter,
164163
user=args.user,
165164
max_entries=args.count,
166165
since=since,
167166
name=args.name,
168167
queue=args.queue,
168+
constraint=args.filter,
169169
)
170170

171171
jobs = jobs_rpc.jobs()
@@ -218,10 +218,9 @@ def parse_args():
218218
parser.add_argument(
219219
"-f",
220220
"--filter",
221-
action=FilterActionSetUpdate,
222-
metavar="STATE|RESULT",
223-
default=set(),
224-
help="List jobs with specific job state or result",
221+
action=FilterActionConcatenate,
222+
metavar="QUERY",
223+
help="Restrict jobs using a constraint query string",
225224
)
226225
parser.add_argument(
227226
"--since",

0 commit comments

Comments
 (0)