dynamo/lib/bindings/python/codegen
Keiven C f2ba58e568
feat: add Rust-to-Python const code generator for prometheus_names.py (#3425)
Signed-off-by: Keiven Chang <keivenchang@users.noreply.github.com>
2025-10-10 11:20:36 -07:00
..
src feat: add Rust-to-Python const code generator for prometheus_names.py (#3425) 2025-10-10 11:20:36 -07:00
templates feat: add Rust-to-Python const code generator for prometheus_names.py (#3425) 2025-10-10 11:20:36 -07:00
Cargo.toml feat: add Rust-to-Python const code generator for prometheus_names.py (#3425) 2025-10-10 11:20:36 -07:00
README.md feat: add Rust-to-Python const code generator for prometheus_names.py (#3425) 2025-10-10 11:20:36 -07:00

README.md

Dynamo Codegen

Python code generator for Dynamo Python bindings.

gen-python-prometheus-names

Generates prometheus_names.py from Rust source lib/runtime/src/metrics/prometheus_names.rs.

Usage

cargo run -p dynamo-codegen --bin gen-python-prometheus-names

What it does

  • Parses Rust AST from lib/runtime/src/metrics/prometheus_names.rs
  • Generates Python classes with constants at lib/bindings/python/src/dynamo/prometheus_names.py
  • Handles macro-generated constants (e.g., kvstats_name!("active_blocks")"kvstats_active_blocks")

Example

Rust input:

pub mod kvstats {
    pub const ACTIVE_BLOCKS: &str = kvstats_name!("active_blocks");
}

Python output:

class kvstats:
    ACTIVE_BLOCKS = "kvstats_active_blocks"

When to run

Run after modifying lib/runtime/src/metrics/prometheus_names.rs to regenerate the Python file.