This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
cargo build- Build the Rust binarycargo build --release- Build optimized release version
cargo test- Run all testscargo test --verbose- Run tests with detailed outputcargo test tests/integration_test.rs- Run specific test file
cargo run -- <input_dir> -o <output_dir>- Run tlparse with argumentscargo run -- --help- Show command helpcargo check- Fast compile check without generating binary
pip install maturin- Install build system for Python bindingsmaturin develop- Install development version in current Python environmentmaturin build- Build Python wheel
- Update version in
Cargo.toml - Run
cargo updateto updateCargo.lock - Create release commit and tag (triggers PyPI release)
- Run
cargo publishto publish to crates.io
Main Library (src/lib.rs)
parse_path()- Primary entry point that processes TORCH_LOG files- Handles glog parsing, JSON deserialization, and coordinates all parsers
- Returns
ParseOutput(vector of file paths and contents to write) - Supports both regular analysis mode and export mode
Type System (src/types.rs)
Envelope- Main structured log entry container with all possible metadata fieldsCompileId- Unique identifier for compilation attempts (frame_id/frame_compile_id/attempt)CompilationMetricsMetadata- Performance and failure tracking dataStackSummaryandFrameSummary- Stack trace representation- Various metadata types for different log entry types
Parser Framework (src/parsers.rs)
StructuredLogParsertrait - Implement to create custom analysis parsersget_metadata()- Filter which log entries a parser processesparse()- Transform log data into output files or linksParserOutputenum - File, GlobalFile, or Link outputs
CLI Interface (src/cli.rs)
- Built with
clapderive macros - Primary command:
tlparse <input_log_file> -o <output_directory> - Supports custom parsers, export mode, and various analysis options
- Log Parsing: Reads TORCH_LOG files line by line using glog regex
- Deserialization: Converts JSON payloads to
Envelopestructs - Parser Execution: Runs all registered parsers on matching envelopes
- Output Generation: Collects files and generates HTML index with navigation
- File Writing: Saves all generated content to output directory
The extensible parser system allows custom analyses:
- Default parsers handle common log types (graphs, metrics, guards)
- Each parser filters relevant envelopes via
get_metadata() - Parsers return files (HTML, JSON, code) or external links
- Results are organized by
CompileIdin the output directory
Uses TinyTemplate for HTML generation:
- Templates defined in
src/templates.rs - CSS and JavaScript embedded as static strings
- Supports both regular and export modes with different templates
- Index pages provide navigation between compilation attempts
- Uses
fxhashfor performance-critical hash maps - Intern table for string deduplication in stack traces
- Progress bars via
indicatiffor large log processing anyhowfor error handling throughout- Supports both Rust binary and Python package builds via
maturin