Skip to content

Commit b6e4da8

Browse files
authored
bugfix: show-config command (#1846)
<!-- .github/pull_request_template.md --> ## 📌 Description I believe the show-config command line option was broken by #1794, because it change the return type of `get_artifacts_status` from a list of size 3 tuples to a tuple of size 2 tuples. This code in `__main__.py` expects the former: ``` status = get_artifacts_status() num_downloaded = sum(1 for _, _, exists in status if exists) total_cubins = len(status) ``` This PR has a fix and a test to protect against future breaks. ## 🔍 Related Issues <!-- Link any related issues here --> ## 🚀 Pull Request Checklist Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete. ### ✅ Pre-commit Checks - [x] I have installed `pre-commit` by running `pip install pre-commit` (or used your preferred method). - [x] I have installed the hooks with `pre-commit install`. - [x] I have run the hooks manually with `pre-commit run --all-files` and fixed any reported issues. > If you are unsure about how to set up `pre-commit`, see [the pre-commit documentation](https://pre-commit.com/). ## 🧪 Tests - [x] Tests have been added or updated as needed. - [x] All tests are passing (`unittest`, etc.). ## Reviewer Notes Is this the right place to add CLI tests? Note that I've added a `tests/cli` subdirectory.
1 parent d3346f6 commit b6e4da8

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

flashinfer/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def show_config_cmd():
114114
click.secho("=== Downloaded Cubins ===", fg="yellow")
115115

116116
status = get_artifacts_status()
117-
num_downloaded = sum(1 for _, _, exists in status if exists)
117+
num_downloaded = sum(1 for _, exists in status if exists)
118118
total_cubins = len(status)
119119

120120
click.secho(f"Downloaded {num_downloaded}/{total_cubins} cubins", fg="cyan")
@@ -137,10 +137,10 @@ def list_cubins_cmd():
137137
"""List downloaded cubins"""
138138
status = get_artifacts_status()
139139
table_data = []
140-
for name, extension, exists in status:
140+
for file_name, exists in status:
141141
status_str = "Downloaded" if exists else "Missing"
142142
color = "green" if exists else "red"
143-
table_data.append([f"{name}{extension}", click.style(status_str, fg=color)])
143+
table_data.append([file_name, click.style(status_str, fg=color)])
144144

145145
click.echo(tabulate(table_data, headers=["Cubin", "Status"], tablefmt="github"))
146146
click.secho("", fg="white")

tests/cli/test_cli_show_config.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from click.testing import CliRunner
2+
3+
from flashinfer.__main__ import cli
4+
5+
6+
def test_show_config_cmd_smoke(monkeypatch):
7+
runner = CliRunner()
8+
result = runner.invoke(cli, ["show-config"])
9+
assert result.exit_code == 0, result.output
10+
out = result.output
11+
12+
# Basic sections present
13+
assert "=== Torch Version Info ===" in out
14+
assert "=== Environment Variables ===" in out
15+
assert "=== Artifact Path ===" in out
16+
assert "=== Downloaded Cubins ===" in out

0 commit comments

Comments
 (0)