Skip to content

Commit

Permalink
flux-jobs: support constraint query string with -f, --filter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
grondo committed Jun 17, 2024
1 parent edff7c1 commit 8dd170a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/cmd/flux-jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from flux.job.stats import JobStats
from flux.util import (
FilterAction,
FilterActionSetUpdate,
FilterActionConcatenate,
FilterTrueAction,
UtilConfig,
help_formatter,
Expand Down Expand Up @@ -151,21 +151,21 @@ def fetch_jobs_flux(args, fields, flux_handle=None):
if args.filter:
LOGGER.warning("Both -a and --filter specified, ignoring -a")
else:
args.filter.update(["pending", "running", "inactive"])
args.filter = "pending,running,inactive"

if not args.filter:
args.filter = {"pending", "running"}
args.filter = "pending,running"

jobs_rpc = JobList(
flux_handle,
ids=args.jobids,
attrs=attrs,
filters=args.filter,
user=args.user,
max_entries=args.count,
since=since,
name=args.name,
queue=args.queue,
constraint=args.filter,
)

jobs = jobs_rpc.jobs()
Expand Down Expand Up @@ -218,10 +218,9 @@ def parse_args():
parser.add_argument(
"-f",
"--filter",
action=FilterActionSetUpdate,
metavar="STATE|RESULT",
default=set(),
help="List jobs with specific job state or result",
action=FilterActionConcatenate,
metavar="QUERY",
help="Restrict jobs using a constraint query string",
)
parser.add_argument(
"--since",
Expand Down

0 comments on commit 8dd170a

Please sign in to comment.