Implementation:Triton inference server Server AddCopyright
| Knowledge Sources | |
|---|---|
| Domains | Developer_Tools, Compliance |
| Last Updated | 2026-02-13 17:00 GMT |
Overview
Concrete tool for automatically adding or updating NVIDIA copyright headers across all source files in the Triton repository.
Description
add_copyright.py walks the repository file tree and manages NVIDIA copyright headers. It identifies file types by extension (C/C++, Python, shell, CMake, Dockerfile), updates existing copyright year ranges to include the current year, and inserts new copyright headers with file-type-specific comment prefixes. It handles shebang-aware insertion for script files and includes built-in pytest tests for validation.
Usage
Run as a developer tool when preparing commits to ensure all modified or new files have proper copyright headers. Can be used as a pre-commit hook or CI check.
Code Reference
Source Location
- Repository: Triton Inference Server
- File: tools/add_copyright.py
- Lines: 1-378
Signature
def has_copyright(content: str) -> bool:
"""Check if file already contains a copyright header."""
def update_copyright_year(content: str, year: int) -> str:
"""Update existing copyright year range to include current year."""
def update_and_get_license(comment_prefix: str) -> str:
"""Generate full NVIDIA license header with given comment prefix."""
def prefix_lines(text: str, prefix: str) -> str:
"""Add comment prefix to each line of license text."""
def insert_after(content: str, marker: str, insertion: str) -> str:
"""Insert copyright after shebang line if present."""
def update_or_add_header(filepath: str, year: int) -> bool:
"""Main entry: update existing or add new copyright header."""
if __name__ == "__main__":
main()
Import
# Standalone script - run directly
python tools/add_copyright.py [directory]
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| directory | path | No | Root directory to scan (defaults to repo root) |
| year | int | No | Copyright year (defaults to current year) |
Outputs
| Name | Type | Description |
|---|---|---|
| modified files | files | Source files with updated/added copyright headers |
| stdout | text | List of modified files and status |
Usage Examples
Add Copyright to All Files
# Update all files in repository
python tools/add_copyright.py
# Update specific directory
python tools/add_copyright.py src/