Skip to content

Commit

Permalink
python: use plugins if available in the jobspec validator
Browse files Browse the repository at this point in the history
Problem: Job submission cli plugins offer a validate() callback,
but this callback is not used.

Load plugins and run all validate callbacks in the jobspec validator
plugin.
  • Loading branch information
grondo committed Dec 12, 2024
1 parent 830e640 commit a969410
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/bindings/python/flux/job/validator/plugins/jobspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@

import json

from flux.cli.plugin import CLIPluginRegistry
from flux.job import validate_jobspec
from flux.job.validator import ValidatorPlugin


class Validator(ValidatorPlugin):
def __init__(self, parser):
self.require_version = 1
self.plugins = []
parser.add_argument(
"--require-version",
metavar="V",
Expand All @@ -47,5 +49,12 @@ def configure(self, args):
raise ValueError(f"Invalid argument to --require-version")
self.require_version = None

self.plugins = CLIPluginRegistry().load_plugins("validate")

def validate(self, args):
validate_jobspec(json.dumps(args.jobspec), self.require_version)
result, jobspec = validate_jobspec(
json.dumps(args.jobspec), self.require_version
)

# validate with any submit cli plugin validate methods
self.plugins.validate(jobspec)

0 comments on commit a969410

Please sign in to comment.