Skip to content

Commit

Permalink
dws2jgf: drop defaults for jgf simplification
Browse files Browse the repository at this point in the history
Problem: JGF is too large, as described in #193.

As a first step to shrink it, do not output default values, instead
skipping them and letting the JGF reader supply them.

Depends on changes introduced in flux-sched by
flux-framework/flux-sched/pull/1293.
  • Loading branch information
jameshcorbett committed Sep 5, 2024
1 parent ea06a5c commit dfd04f1
Showing 1 changed file with 20 additions and 63 deletions.
83 changes: 20 additions & 63 deletions src/cmd/flux-dws2jgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class ElCapResourcePoolV1(FluxionResourcePoolV1):
"""

@staticmethod
def constraints(resType):
return resType in [
def constraints(resource_type):
return resource_type in [
"rack",
"rabbit",
"ssd",
] or super(
ElCapResourcePoolV1, ElCapResourcePoolV1
).constraints(resType)
).constraints(resource_type)

@property
def path(self):
Expand Down Expand Up @@ -66,67 +66,26 @@ def __init__(self, rv1, rabbit_mapping, r_hostlist, chunks_per_nnf, cluster_name
# Call super().__init__() last since it calls __encode
super().__init__(rv1)

def _encode_rank(self, parent, rank, children, hName):
hPath = f"{parent.path}/{hName}"
iden = self._extract_id_from_hn(hName)
vtx = ElCapResourcePoolV1(
self._uniqId,
"node",
"node",
hName,
iden,
self._uniqId,
rank,
True,
"",
1,
self._rank_to_properties.get(rank, {}),
hPath,
)
edg = ElCapResourceRelationshipV1(parent.get_id(), vtx.get_id())
self._add_and_tick_uniq_id(vtx, edg)
for key, val in children.items():
for i in IDset(val):
self._encode_child(vtx.get_id(), hPath, rank, str(key), i, {})

def _encode_ssds(self, parent, capacity):
res_type = "ssd"
for i in range(self._chunks_per_nnf):
res_name = f"{res_type}{i}"
vtx = ElCapResourcePoolV1(
self._uniqId,
res_type,
res_type,
res_name,
i,
self._uniqId,
-1,
True,
"GiB",
to_gibibytes(capacity // self._chunks_per_nnf),
{},
f"{parent.path}/{res_name}",
1, # status=1 marks the ssds as 'down' initially
iden=i,
unit="GiB",
size=to_gibibytes(capacity // self._chunks_per_nnf),
status=1, # status=1 marks the ssds as 'down' initially
)
edg = ElCapResourceRelationshipV1(parent.get_id(), vtx.get_id())
self._add_and_tick_uniq_id(vtx, edg)

def _encode_rack(self, parent, rabbit_name, entry):
res_type = "rack"
res_name = f"{res_type}{self._rackids}"
vtx = ElCapResourcePoolV1(
self._uniqId,
res_type,
res_type,
res_name,
self._rackids,
self._uniqId,
-1,
True,
"",
1,
{"rabbit": rabbit_name, "ssdcount": str(self._chunks_per_nnf)},
f"{parent.path}/{res_name}",
"rack",
iden=self._rackids,
properties={"rabbit": rabbit_name, "ssdcount": str(self._chunks_per_nnf)},
)
edg = ElCapResourceRelationshipV1(parent.get_id(), vtx.get_id())
self._add_and_tick_uniq_id(vtx, edg)
Expand All @@ -137,30 +96,28 @@ def _encode_rack(self, parent, rabbit_name, entry):
except FileNotFoundError:
pass
else:
self._encode_rank(vtx, index, self._rank_to_children[index], node)
self._encode_rank(
vtx.get_id(),
index,
self._rank_to_children[index],
node,
self._rank_to_properties.get(index, {}),
)
# if the rabbit itself is in R, add it to the rack as a compute node as well
try:
index = self._r_hostlist.index(rabbit_name)[0]
except FileNotFoundError:
pass
else:
self._encode_rank(vtx, index, self._rank_to_children[index], rabbit_name)
self._encode_rank(
vtx, index, self._rank_to_children[index], rabbit_name, None
)
self._rackids += 1

def _encode(self):
vtx = ElCapResourcePoolV1(
self._uniqId,
"cluster",
self._cluster_name,
self._cluster_name + "0",
0,
self._uniqId,
-1,
True,
"",
1,
{},
f"/{self._cluster_name}0",
)
self._add_and_tick_uniq_id(vtx)
for rabbit_name, entry in self._rabbit_mapping["rabbits"].items():
Expand Down

0 comments on commit dfd04f1

Please sign in to comment.