Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CABLE non-zero exit code behaviour #83

Merged
merged 2 commits into from
May 24, 2023

Conversation

SeanBryan51
Copy link
Collaborator

This commit fixes the following bugs in run_tasks():

  • If subprocess.run raises an exception, we still attempt to add attributes to the netcdf file. This change fixes this by continuing to the next task immediately on failure.
  • The command to run CABLE does not redirect the stderr stream of CABLE. As a result, error messages are printed to the stderr of benchcab. This change fixes this by redirecting the CABLE stderr to its stdout stream so that the stderr from CABLE is written to out.txt.
  • The error message "Job failed to submit: " is printed when CABLE exits with a non-zero exit code which is misleading. This change updates the error message to state that CABLE has failed and the task name of the failed task.

Fixes #56

This commit fixes the following bugs in `run_tasks()`:
- If `subprocess.run` raises an exception, we still
  attempt to add attributes to the netcdf file. This change fixes this
  by continuing to the next task immediately on failure.
- The command to run CABLE does not redirect the stderr stream of CABLE.
  As a result, error messages are printed to the stderr of `benchcab`.
  This change fixes this by redirecting the CABLE stderr to its stdout
  stream so that the stderr from CABLE is written to `out.txt`.
- The error message "Job failed to submit: <cmd>" is printed when CABLE
  exits with a non-zero exit code which is misleading. This change
  updates the error message to state that CABLE has failed and the
  task name of the failed task.

Fixes #56
@SeanBryan51 SeanBryan51 linked an issue May 18, 2023 that may be closed by this pull request
@SeanBryan51
Copy link
Collaborator Author

Ideally this PR should go in after #82 has been merged (this allows me to test other branches of CABLE which fail in some configurations instead of using my own branches of CABLE which run successfully).

@SeanBryan51 SeanBryan51 requested a review from ccarouge May 18, 2023 01:58
Copy link
Member

@ccarouge ccarouge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a small change in the error message but otherwise it is good to go.

except subprocess.CalledProcessError as err:
print("Job failed to submit: ", err.cmd)
except subprocess.CalledProcessError:
print(f"Error: CABLE returned a non-zero exit code for task {task_name}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(f"Error: CABLE returned a non-zero exit code for task {task_name}")
print(f"Error: CABLE returned an error for task {task_name}")

I'm not sure everyone knows what "a non-zero exit code" means.

@ccarouge ccarouge merged commit 528b9cf into master May 24, 2023
@ccarouge ccarouge deleted the 56-fix-cable-non-zero-exit-code-behaviour branch May 24, 2023 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

run_tasks() breaks when CABLE returns a non-zero exit code.
2 participants