Skip to content

Commit

Permalink
Fixed style issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Ferrell committed Aug 7, 2023
1 parent 68c7f59 commit 3fcc898
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 57 deletions.
11 changes: 6 additions & 5 deletions lib/pavilion/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def _setup_arguments(self, parser):
nodes_parser = subparsers.add_parser(
'nodes',
help="Show node status for the current machine, from Pavilion's perspective.",
description="""Display a table of information on the current state
of system nodes for a given scheduler."""
description="Display a table of information on the current state of "
"system nodes for a given scheduler."
)

nodes_plugins = []
Expand Down Expand Up @@ -635,15 +635,17 @@ def _module_wrappers_cmd(self, _, args):

@sub_cmd()
def _nodes_cmd(self, pav_cfg, args):

"""Lists the nodes as seen by a given scheduler."""
# pylint: disable=protected-access

sched = schedulers.get_plugin(args.scheduler)

if args.test is not None:
try:
rslvr = resolver.TestConfigResolver(pav_cfg)
ptests = rslvr.load([args.test])
except errors.TestConfigError as err:
output.fprint(self.errfile,
output.fprint(self.errfile,
"Could not load test {}\n{}"
.format(args.test, err.pformat()))
return errno.EINVAL
Expand All @@ -655,7 +657,6 @@ def _nodes_cmd(self, pav_cfg, args):
if not test.skipped:
break
except errors.PavilionError as err:
print(err)
continue

if test is not None:
Expand Down
43 changes: 13 additions & 30 deletions lib/pavilion/schedulers/plugins/flux.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# pylint: disable=too-many-lines
"""The Flux Framework Scheduler Plugin."""

import os, sys, subprocess
import os
import sys
import subprocess
import time
from typing import List, Union, Any, Tuple

Expand All @@ -26,28 +28,9 @@
import flux.job
import flux.resource
from flux.job import JobspecV1
HAS_FLUX = True
except ImportError:
minor_version = sys.version_info.minor
if minor_version < 6:
message = "Python minor version {} is too low.".format(minor_version)
raise ImportError(message)
flux_path = None
for i in range(minor_version, 5, -1):
test_flux_path = "/usr/lib64/flux/python3." + str(minor_version)
if not os.path.exists(test_flux_path):
pass
else:
flux_path = test_flux_path
break
sys.path.append(flux_path)
try:
import flux
import flux.hostlist
import flux.job
import flux.resource
from flux.job import JobspecV1
except ImportError:
flux = None
HAS_FLUX = False

flux_states = [
"DEPEND",
Expand Down Expand Up @@ -263,10 +246,10 @@ def _get_alloc_nodes(self, job) -> NodeList:
jobid = flux.job.job_list_id(parent_handle, child_jobid).get_jobinfo()

# Get compressed nodelist
nodes = jobid._nodelist
nodes = jobid._nodelist # pylint: disable=protected-access
# Expand the nodelist as necessary
# Either it's a single node and just needs to be in a list
if jobid._nnodes == 1:
if jobid._nnodes == 1: # pylint: disable=protected-access
nodes = [nodes]
# Or, it's a compressed format of a node list and must be expanded
elif not isinstance(nodes, list):
Expand Down Expand Up @@ -304,7 +287,8 @@ def _available(self) -> bool:
"""
Ensure we can import and talk to flux.
"""
return flux is not None

return HAS_FLUX

def _kickoff(self, pav_cfg, job: Job, sched_config: dict, job_name: str,
nodes: Union[NodeList, None] = None,
Expand Down Expand Up @@ -347,8 +331,8 @@ def _kickoff(self, pav_cfg, job: Job, sched_config: dict, job_name: str,
flux_return = flux.job.submit(flux.Flux(), fluxjob)

jobid = flux_return
job._jobid = str(jobid)
job._submit_time = time.time()
job._jobid = str(jobid) # pylint: disable=protected-access
job._submit_time = time.time() # pylint: disable=protected-access
sys_name = sys_vars.get_vars(True)["sys_name"]

return JobInfo(
Expand Down Expand Up @@ -406,9 +390,8 @@ def _job_status(self, pav_cfg, job_info: JobInfo) -> TestStatusInfo:
return TestStatusInfo(
state=STATES.BUILD_WAIT,
note=(
"Job is waiting for a dependency or priority assignment. Has job state {}".format(
flux_job.state
)
"Job is waiting for a dependency or priority assignment. "
"Has job state {}".format(flux_job.state)
),
when=time.time(),
)
Expand Down
21 changes: 1 addition & 20 deletions lib/pavilion/test_run/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,28 +526,9 @@ def _save_config(self):
while time.time() - start < 100:
try:
tmp_path.rename(config_path)
print('tmp_testing', tmp_path, config_path, tmp_path.exists(), config_path.exists(), config_path.parent.exists())
break
except (FileNotFoundError):
except FileNotFoundError:
continue
# try:
# with tmp_path.open('w') as config_file:
#
# yaml.dump(config, config_file)
# try:
# config_path.unlink()
# except OSError:
# pass
# print('tmp_testing', tmp_path, config_path, tmp_path.exists(), config_path.exists(), config_path.parent.exists())
# tmp_path.rename(config_path)
# except (OSError, IOError) as err:
# raise TestRunError(
# "Could not save TestRun ({}) config at {}"
# .format(self.name, self.path), err)
# except TypeError as err:
# raise TestRunError(
# "Invalid type in config for ({})"
# .format(self.name), err)

@classmethod
def _load_config(cls, test_path):
Expand Down
3 changes: 1 addition & 2 deletions lib/pavilion/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,8 @@ def save(self, path):
while time.time() - start < 100:
try:
tmp_path.rename(path)
print('tmp_testing', tmp_path, path, tmp_path.exists(), path.exists(), path.parent.exists())
break
except (FileNotFoundError):
except FileNotFoundError:
continue

@classmethod
Expand Down

0 comments on commit 3fcc898

Please sign in to comment.