Improve code quality, error handling, and UX#1
Merged
Conversation
…rbose/--quiet/--output-dir flags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves code quality, error handling, user experience, and test coverage across the ttperf codebase. All existing CLI flags and behaviours are preserved.
Changes
1. Dynamic version from package metadata
"ttperf version 0.1.7"string fromparse_args()importlib.metadata.version("ttperf")with a"dev"fallback, eliminating version drift betweenpyproject.tomland the source file2. Better CSV error messages
get_device_kernel_duration()now prints all available column names when the expectedDEVICE KERNEL DURATION [ns]column is missing, making it much easier to diagnose CSV format issues3. File existence check after path extraction
extract_csv_path()now verifies the extracted CSV path exists on disk before returning it, with a clear error message if the file is absent4.
--verbose/-vflag and proper loggingimport loggingand a module-levellogger = logging.getLogger(__name__)--verbosesetslogging.DEBUG; without it, onlyWARNINGand above are shown"Warning: could not parse test file", subprocess debug info) moved tologger.debug()/logger.warning(); user-facing result output stays asprint()-vshorthand for--versionwas removed (only--versiontriggers version output now) since-vis the conventional shorthand for verbose5.
--quiet/-qflagset_test_configuration()and the auto-generated profile name line6.
--output-dirflagos.makedirs(exist_ok=True)if it does not exist7. Config file support (
~/.ttperf.yaml/./.ttperf.yaml)load_config_file()checks for a YAML config file (local directory first, then home directory)argparsedefaults; CLI flags always winconfigparser(ini-style) if not — no hard new dependency8. README improvements
https://img.shields.io/badge/version-0.1.6-orange.svgto the dynamic PyPI badgehttps://img.shields.io/pypi/v/ttperf.svg--verbose,--quiet,--output-dir)~/.ttperf.yaml--quiet-mode output accuratelytests/9. Unit tests (
tests/test_ttperf.py)extract_csv_path,get_device_kernel_duration,parse_shape,validate_dtype,validate_layout,generate_profile_name,load_config_file,extract_test_config_and_status, and__version__unittest.mockto avoid requiring a real TT-Metal environment10. CI workflow updates (
.github/workflows/test.yml)pip install -e ".[dev]"to getpytestandpytest-covpytest tests/ -v --cov=ttperf --cov-report=term-missing --cov-report=xmlpytestconfiguration andcoveragesettings topyproject.toml11.
pyproject.tomladditions[dev](pytest, pytest-cov) and[yaml](PyYAML)[tool.pytest.ini_options]and[tool.coverage.run]sectionsWhat was intentionally NOT changed
ttperf.pyintocli.py,csv_parser.py,profiler.py): At ~460 lines the file is manageable and splitting would require updating imports across test files, the entry point, and any downstream consumers. Deferred to a dedicated refactor PR.--debug,--shape,--dtype,--layout,--memory-config,--dram,--l1,--list-ops) continue to work unchanged.pkg_resourcesremoval: Kept as a fallback inload_operation_configs()sinceimportlib.resourcesAPI changed between Python 3.8 and 3.9; the function tries the modern API first.Test plan
pip install -e ".[dev]"succeedspytest tests/ -vpasses all teststtperf --versionoutputs the version frompyproject.tomlttperf --helpshows the updated help text including new flagsttperf --quiet addproduces clean output without decorative prefixesttperf --verbose addshows debug log linesttperf add --output-dir /tmp/resultscopies CSV to/tmp/results/~/.ttperf.yamlwithdtype: float32and runningttperf addpicks up the default🤖 Generated with Claude Code