From 96f8ffa5eea511290f203c5d13484731e7d82387 Mon Sep 17 00:00:00 2001 From: Freddy Boulton Date: Mon, 12 Aug 2024 12:09:52 -0700 Subject: [PATCH] Set non-zero exit codes for custom component build and install commands when failures occur (#9088) * Exit codes * add changeset * Fix text --------- Co-authored-by: gradio-pr-bot --- .changeset/every-parks-count.md | 5 +++++ gradio/cli/commands/components/build.py | 3 ++- gradio/cli/commands/components/install_component.py | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/every-parks-count.md diff --git a/.changeset/every-parks-count.md b/.changeset/every-parks-count.md new file mode 100644 index 0000000000000..2ec1438413402 --- /dev/null +++ b/.changeset/every-parks-count.md @@ -0,0 +1,5 @@ +--- +"gradio": patch +--- + +fix:Set non-zero exit codes for custom component build and install commands when failures occur diff --git a/gradio/cli/commands/components/build.py b/gradio/cli/commands/components/build.py index 489c600043b55..3c0bfed5e1977 100644 --- a/gradio/cli/commands/components/build.py +++ b/gradio/cli/commands/components/build.py @@ -162,7 +162,7 @@ def _build( live.update(":red_square: Build failed!") live.update(pipe.stderr) live.update(pipe.stdout) - return + raise SystemExit("Frontend build failed") else: live.update(":white_check_mark: Build succeeded!") @@ -172,6 +172,7 @@ def _build( if pipe.returncode != 0: live.update(":red_square: Build failed!") live.update(pipe.stderr) + raise SystemExit("Python build failed") else: live.update(":white_check_mark: Build succeeded!") live.update( diff --git a/gradio/cli/commands/components/install_component.py b/gradio/cli/commands/components/install_component.py index 37da0fed6db31..08092e76d7607 100644 --- a/gradio/cli/commands/components/install_component.py +++ b/gradio/cli/commands/components/install_component.py @@ -71,6 +71,8 @@ def _install_command( if pipe.returncode != 0: live.update(":red_square: Python installation [bold][red]failed[/][/]") live.update(pipe.stderr) + raise SystemExit("Python installation failed") + else: live.update(":white_check_mark: Python install succeeded!") @@ -85,6 +87,7 @@ def _install_command( live.update(":red_square: NPM install [bold][red]failed[/][/]") live.update(pipe.stdout) live.update(pipe.stderr) + raise SystemExit("NPM install failed") else: live.update(":white_check_mark: NPM install succeeded!")