Skip to content

Commit

Permalink
python: extend submission cli commands with plugins
Browse files Browse the repository at this point in the history
Problem: Flux submission cli commands don't support plugins.

Load any plugins in the default plugin path
"{confdir}/cli/plugins/*.py" and call any plugin `add_options()` and
`modify_jobspec()` callbacks at appropriate points.
  • Loading branch information
grondo committed Dec 13, 2024
1 parent 3ca3932 commit c6c2b31
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/bindings/python/flux/cli/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import flux
from flux import debugged, job, util
from flux.cli.plugin import CLIPluginRegistry
from flux.constraint.parser import ConstraintParser, ConstraintSyntaxError
from flux.idset import IDset
from flux.job import JobspecV1, JobWatcher
Expand Down Expand Up @@ -741,7 +742,9 @@ def __init__(self, prog, usage=None, description=None, exclude_io=False):
self.exitcode = 0
self.progress = None
self.watcher = None
self.plugins = CLIPluginRegistry().load_plugins(prog)
self.parser = self.create_parser(prog, usage, description, exclude_io)
self.plugins.add_options(self.parser)

@staticmethod
def create_parser(
Expand Down Expand Up @@ -1000,6 +1003,9 @@ def jobspec_create(self, args):
"""
Create a jobspec from args and return it to caller
"""
# allow plugins to initialize args
self.plugins.preinit(args)

jobspec = self.init_jobspec(args)
jobspec.environment = get_filtered_environment(args.env)
jobspec.cwd = args.cwd if args.cwd is not None else os.getcwd()
Expand Down Expand Up @@ -1111,6 +1117,8 @@ def jobspec_create(self, args):
for arg in args.add_file:
self.handle_add_file_arg(jobspec, arg)

self.plugins.modify_jobspec(args, jobspec)

return jobspec

def submit_async(self, args, jobspec=None):
Expand Down

0 comments on commit c6c2b31

Please sign in to comment.