flux.resource.Rv1Set module
Pure-Python Rv1 implementation of the ResourceSetImplementation ABC.
Rv1Set stores resources as a per-rank dict
{hostname, cores, gpus} and a property mapping
{name: set-of-ranks}. It implements all abstract methods of
ResourceSetImplementation
and supports set operations (union, diff, intersect, append, add),
properties, constraints, and round-trip serialization of the RFC 20 Rv1 R
format.
- class flux.resource.Rv1Set.Rv1Set(arg=None, keep_scheduling: bool = False)
Bases:
ResourceSetImplementationPure-Python Rv1 ResourceSetImplementation.
Internal representation:
_ranks: mapping from rank integer to{hostname: str, cores: frozenset, gpus: frozenset}_properties: mapping from property name to the set of ranks that carry that property_expiration,_starttime: resource-set timestamps (float, seconds since epoch; 0 = unset)
Set operations (diff, intersect) operate at core/GPU ID granularity. Properties are propagated to the result sets by intersection.
The constructor accepts any of:
Noneor no argument → empty setan R JSON string
a parsed R JSON dict (
{"version": 1, "execution": {...}})
- add(other: Rv1Set) None
Add ranks from other into self (mutating).
For ranks not yet in self, the rank is copied from other. For ranks already in self, the core and GPU ID sets are unioned so that merging disjoint subsets of a resource set (e.g. free + allocated) reconstructs the full topology.
- append(other: Rv1Set) None
Add all ranks from other into self (mutating).
For ranks already in self, core and GPU ID sets are unioned so that appending disjoint subsets of a rank (e.g. core[0-3] then core[4-7]) merges them, matching C rlist_append / rnode_add behaviour.
- copy_constraint(constraint) Rv1Set
Return a copy containing only ranks that satisfy constraint.
constraint may be an RFC 31 constraint dict or a JSON string.
- count(name: str) int
Return total count of name (
"core"or"gpu") across all ranks.
- diff(other: Rv1Set) Rv1Set
Return a new Rv1Set with resources in self not in other.
Matching ranks have their core and GPU ID sets reduced by the IDs in other (mirroring the C rlist_diff / rnode_diff behaviour). Ranks with no remaining resources are dropped from the result.
- dumps() str
Return a compact human-readable summary.
Format:
rank<idset>/core<idset>[,gpu<idset>][+...]
- encode() str
Serialize to an R JSON string.
- get_expiration() float
Return the resource set expiration (seconds since epoch, 0 = none).
- get_properties() str
Return an RFC 20 properties JSON object string.
- get_starttime() float
Return the resource set start time (seconds since epoch, 0 = none).
- nnodes() int
Return the number of nodes (ranks) in this set.
- property scheduling
Return the opaque R.scheduling key, or None if not set.
The
R.schedulingkey is an optional RFC 20 field carrying scheduler-private data. Schedulers that setkeep_scheduling=Truein the constructor will preserve this field so it can be propagated to allocations.
- set_expiration(expiration: float) None
Set the resource set expiration (seconds since epoch, 0 = none).
- set_property(name: str, ranks=None) Rv1Set
Set property name on ranks (or all ranks if ranks is
None).
- set_starttime(starttime: float) None
Set the resource set start time (seconds since epoch).
- to_dict() dict
Return the resource set as a parsed R JSON dict.
- union(other: Rv1Set) Rv1Set
Return a new Rv1Set with the union of resources from self and other.
For ranks present in both operands, core and GPU ID sets are unioned (true ID-level union, mirroring C rlist_union / rnode_union behaviour).
- version = 1