Nodeset: add --index command to cluset/nodeset by thiell · Pull Request #637 · clustershell/clustershell · GitHub
Skip to content

Nodeset: add --index command to cluset/nodeset#637

Merged
thiell merged 1 commit into
clustershell:masterfrom
thiell:feature/gh631-cluset-index
Jun 27, 2026
Merged

Nodeset: add --index command to cluset/nodeset#637
thiell merged 1 commit into
clustershell:masterfrom
thiell:feature/gh631-cluset-index

Conversation

@thiell

@thiell thiell commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Add a --index NODE command to cluset/nodeset that outputs the zero-based position of a node in the resulting node set. It is the command-line front-end to the NodeSet.index() / RangeSet.index() methods (#631) and the inverse of -I/--slice. Suggested by @mattaezell in #631.

$ cluset --index node5 node[0-9]
5
$ cluset -R --index 18 1,5,18-31
2

A node that is not in the set prints an error on stderr and exits non-zero (like list.index()), so it doubles as a membership test:

$ cluset --index $(hostname) $SLURM_JOB_NODELIST   # rank on stdout, or exit 1

Notes:

  • It is a command (mutually exclusive with -c/-e/-f/...), computed on the final set, so it honors -x/-i/-X, -I/--slice and stdin, and works in RangeSet mode (-R).
  • --index combined with --pick is rejected, since random sampling would make the position meaningless.
  • The position follows ClusterShell's own ordering (same as -e/--expand); the docs cover the non-obvious cases (alphabetical pattern order, multidimensional flattening) and warn it is not guaranteed to match a resource manager's rank such as Slurm's $SLURM_NODEID.

See #631.

@thiell thiell requested a review from degremont June 25, 2026 06:08
@degremont

Copy link
Copy Markdown
Collaborator

Add a --index NODE command that outputs the zero-based position of a
node in the resulting set, the reverse of -I/--slice. Works in both
NodeSet and RangeSet (-R) modes.

Signed-off-by: Stephane Thiell <sthiell@stanford.edu>
@thiell thiell force-pushed the feature/gh631-cluset-index branch from 30412bb to 1d06faa Compare June 27, 2026 12:46
@thiell thiell added this to the 1.10 milestone Jun 27, 2026
@thiell thiell added this pull request to the merge queue Jun 27, 2026
Merged via the queue into clustershell:master with commit 8755d96 Jun 27, 2026
9 checks passed
@thiell thiell added the Scripts label Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants