Skip to content

Commit 3c5fcd9

Browse files
committed
ion-resource: add support for growing allocation
1 parent 53da661 commit 3c5fcd9

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/cmd/flux-ion-resource.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ def rpc_allocate(self, jobid, jobspec_str):
4444
payload = {"cmd": "allocate", "jobid": jobid, "jobspec": jobspec_str}
4545
return self.handle.rpc("sched-fluxion-resource.match", payload).get()
4646

47+
def rpc_match_grow(self, jobid, jobspec_str):
48+
payload = {"cmd": "grow_allocation", "jobid": jobid, "jobspec": jobspec_str}
49+
return self.handle.rpc("sched-fluxion-resource.match", payload).get()
50+
4751
def rpc_update(self, jobid, Res):
4852
payload = {"jobid": jobid, "R": Res}
4953
return self.handle.rpc("sched-fluxion-resource.update", payload).get()
@@ -135,6 +139,23 @@ def match_alloc_action(args):
135139
print(resp["R"])
136140

137141

142+
def match_grow_action(args):
143+
"""
144+
Action for match grow sub-command
145+
"""
146+
147+
with open(args.jobspec, "r") as stream:
148+
jobspec_str = yaml.dump(yaml.safe_load(stream))
149+
jobid = args.jobid
150+
rmormod = ResourceModuleInterface()
151+
resp = rmormod.rpc_match_grow(jobid, jobspec_str)
152+
print(heading())
153+
print(body(resp["jobid"], resp["status"], resp["at"], resp["overhead"]))
154+
print("=" * width())
155+
print("MATCHED RESOURCES:")
156+
print(resp["R"])
157+
158+
138159
def match_alloc_sat_action(args):
139160
"""
140161
Action for match allocate_with_satisfiability sub-command
@@ -430,6 +451,10 @@ def parse_match(parser_m: argparse.ArgumentParser):
430451
parser_ma = subparsers_m.add_parser(
431452
"allocate", help="Allocate the best matching resources if found."
432453
)
454+
parser_mg = subparsers_m.add_parser(
455+
"grow_allocation",
456+
help="Grow allocation with the best matching resources if found.",
457+
)
433458
parser_ms = subparsers_m.add_parser(
434459
"allocate_with_satisfiability",
435460
help=(
@@ -451,12 +476,15 @@ def parse_match(parser_m: argparse.ArgumentParser):
451476
#
452477
# Jobspec positional argument for all match sub-commands
453478
#
454-
for subparser in parser_ma, parser_ms, parser_mr, parser_fe:
479+
for subparser in parser_ma, parser_mg, parser_ms, parser_mr, parser_fe:
455480
subparser.add_argument(
456481
"jobspec", metavar="Jobspec", type=str, help="Jobspec file name"
457482
)
483+
# Add jobid positional argument for match grow
484+
parser_mg.add_argument("jobid", metavar="Jobid", type=JobID, help="Jobid")
458485

459486
parser_ma.set_defaults(func=match_alloc_action)
487+
parser_mg.set_defaults(func=match_grow_action)
460488
parser_ms.set_defaults(func=match_alloc_sat_action)
461489
parser_mr.set_defaults(func=match_reserve_action)
462490
parser_fe.set_defaults(func=satisfiability_action)

0 commit comments

Comments
 (0)