Skip to content

Add option to exit with error status if workflow is incomplete#108

Merged
maddenp-cu merged 7 commits intoNOAA-GSL:mainfrom
maddenp-cu:fail
Feb 24, 2026
Merged

Add option to exit with error status if workflow is incomplete#108
maddenp-cu merged 7 commits intoNOAA-GSL:mainfrom
maddenp-cu:fail

Conversation

@maddenp-cu
Copy link
Collaborator

No description provided.

cfgfile = tmp_path / "config.yaml"
with cfgfile.open("w") as f:
yaml.safe_dump(config_data, f)
cfgfile.write_text(yaml.safe_dump(config_data))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In a few places, I simplified code slightly by using Path.read_text() or Path.write_text().

Comment on lines +87 to +106
@mark.parametrize("switch", ["-f", "--fail", None])
def test_cli_main__fail(config_data, switch, tmp_path):
@external
def bad(_):
yield "bad"
yield Asset(None, lambda: False)

cfgfile = tmp_path / "config.yaml"
cfgfile.write_text(yaml.safe_dump(config_data))
argv = [pkgname, "-c", str(cfgfile), "-t", "bad", switch]
with (
patch.object(cli.sys, "argv", list(filter(None, argv))),
patch.object(workflow, "bad", create=True, new=bad),
):
if switch:
with raises(SystemExit) as e:
cli.main()
assert e.value.code == 1
else:
cli.main()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Test for the new feature.

I also verified manually with a real config and vx use case.

cli.main()
assert e.value.code == 1
assert "No such task: foo" in caplog.messages
assert logged("No such task: foo")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I simplified a few tests by using the logged fixture instead of interacting with caplog directly.

Comment on lines +39 to +41
node = task(c, threads=args.threads)
if args.fail and not node.ready:
fail(f"Task '{args.task}' is incomplete")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Main logic for the new feature.

Comment on lines +90 to +95
optional.add_argument(
"-f",
"--fail",
action="store_true",
help="Exit with error status if task is incomplete",
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add the new feature to the CLI.

@maddenp-cu maddenp-cu marked this pull request as ready for review February 24, 2026 21:01
Copy link
Collaborator

@elcarpenterNOAA elcarpenterNOAA left a comment

Choose a reason for hiding this comment

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

Thank you!

Co-authored-by: Emily Carpenter <137525341+elcarpenterNOAA@users.noreply.github.com>
@maddenp-cu maddenp-cu merged commit e34952a into NOAA-GSL:main Feb 24, 2026
1 check passed
@maddenp-cu maddenp-cu deleted the fail branch February 24, 2026 22:26
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.

2 participants