Skip to content

Commit

Permalink
Simplify retrieving info about slurm.err file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jendrikseipp committed Jul 8, 2021
1 parent fd7cc76 commit 3a3e5e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
18 changes: 9 additions & 9 deletions downward/reports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,20 @@ def _get_warnings_text_and_table(self):
slurm_err_file = src_dir + "-grid-steps/slurm.err"
try:
slurm_err_content = tools.get_slurm_err_content(src_dir)
except OSError:
slurm_err_content = (
"The slurm.err file was missing while creating the report."
except FileNotFoundError:
slurm_err_file = "*-grid-steps/slurm.err"
errors.append(
f"There was output to {slurm_err_file}, but the file was missing when "
f"this report was made."
)
else:
slurm_err_content = tools.filter_slurm_err_content(slurm_err_content)

errors.append(
f"There was output to {slurm_err_file}. Below is the output without"
f'"memory cg" errors:\n```\n{slurm_err_content}\n```'
)
logging.error(f"There was output to {slurm_err_file}.")

errors.append(
f' Contents of {slurm_err_file} without "memory cg"'
f" errors:\n```\n{slurm_err_content}\n```"
)

if table:
errors.append(str(table))

Expand Down
14 changes: 3 additions & 11 deletions lab/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,17 +495,9 @@ def get_unexplained_errors_message(run):

def get_slurm_err_content(src_dir):
grid_steps_dir = src_dir.rstrip("/") + "-grid-steps"
if os.path.exists(grid_steps_dir):
slurm_err_filename = os.path.join(grid_steps_dir, "slurm.err")
if os.path.exists(slurm_err_filename):
try:
with open(slurm_err_filename) as f:
return f.read()
except OSError:
logging.error("Failed to read slurm.err file.")
else:
logging.error("File slurm.err is missing.")
return ""
slurm_err_filename = os.path.join(grid_steps_dir, "slurm.err")
with open(slurm_err_filename) as f:
return f.read()


def filter_slurm_err_content(content):
Expand Down

0 comments on commit 3a3e5e5

Please sign in to comment.