Skip to content

Commit 5f7da9e

Browse files
committed
python: add 'status' to ResourcePool constructor
Problem: the FluxionResourcePoolV1 does not support setting vertex status. However, some resources, such as rabbits, should be initialized as down, and are only known to Fluxion through JGF produced by the FluxResourcePool class. Add a 'status' parameter to the FluxionResourcePoolV1 constructor, with a default of 'up' to maintain backwards compatibility.
1 parent d51c81f commit 5f7da9e

File tree

1 file changed

+18
-17
lines changed
  • src/python/fluxion/resourcegraph

1 file changed

+18
-17
lines changed

src/python/fluxion/resourcegraph/V1.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __init__(
3535
size,
3636
properties,
3737
path,
38+
status=0,
3839
):
3940
"""Constructor
4041
@@ -51,26 +52,26 @@ def __init__(
5152
size -- Amount of individual resources in this resource pool in unit
5253
properties -- Comma-separated list of property strings
5354
paths -- Fully qualified paths dictionary
55+
status -- Resource status (0 for 'up', 1 for 'down'), defaults to 0
5456
"""
5557
if not self.constraints(resType):
5658
raise ValueError(f"resource type={resType} unsupported by RV1")
57-
58-
super(FluxionResourcePoolV1, self).__init__(
59-
vtxId,
60-
metadata={
61-
"type": resType,
62-
"basename": basename,
63-
"name": name,
64-
"id": iden,
65-
"uniq_id": uniqId,
66-
"rank": rank,
67-
"exclusive": exclusive,
68-
"unit": unit,
69-
"size": size,
70-
"properties": properties,
71-
"paths": {"containment": path},
72-
},
73-
)
59+
metadata = {
60+
"type": resType,
61+
"basename": basename,
62+
"name": name,
63+
"id": iden,
64+
"uniq_id": uniqId,
65+
"rank": rank,
66+
"exclusive": exclusive,
67+
"unit": unit,
68+
"size": size,
69+
"properties": properties,
70+
"paths": {"containment": path},
71+
}
72+
if status != 0: # reduce the footprint by only adding status if nonzero
73+
metadata["status"] = status
74+
super(FluxionResourcePoolV1, self).__init__(vtxId, metadata=metadata)
7475

7576
@staticmethod
7677
def constraints(resType):

0 commit comments

Comments
 (0)