Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Python Code Style Check

# Trigger on push to main/master branches or pull requests targeting them
on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]

permissions:
contents: read

jobs:
style_check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"] # We can add more versions here, e.g., ["3.8", "3.10"]

steps:
# 1. Checkout code
- uses: actions/checkout@v4

# 2. Set up Python environment
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # Enable pip caching to speed up future builds

# 3. Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Install linting and formatting tools
pip install flake8 black

# Install project dependencies (if requirements.txt exists)
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

# 4. Linting with flake8
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

# 5. Check formatting with Black
- name: Check formatting with Black
run: |
# --check only verifies formatting without modifying files.
# The CI will fail if the code is not formatted correctly.
black . --check --verbose
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# InfiniMetrics

<div align="center">

# InfiniMetrics

**An InfiniTensor-Featured Comprehensive Accelerator Evaluation Framework**

[![Format Check](https://img.shields.io/badge/Format_Check-passing-success)](https://github.com/InfiniTensor/InfiniMetrics)
Expand Down Expand Up @@ -42,6 +42,7 @@ For detailed guides, configuration, and examples, see the [full documentation](.

- [Installation Guide](./docs/installation.md) - Prerequisites and dependencies
- [Configuration](./docs/configuration.md) - Input format and parameters
- [Development Guide](./docs/development.md) - Development setup and extending the framework

---

Expand Down
44 changes: 43 additions & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@
# Development Guide

This guide explains how to extend InfiniMetrics by adding new adapters and metrics.
This guide explains how to set up the development environment and extend InfiniMetrics by adding new adapters and metrics.

## Development Setup

### Pre-commit Setup

This project uses **pre-commit** to automatically enforce code style (Black) and linting (Flake8) before every commit.

#### Installation

```bash
pip install pre-commit
```

#### Setup (Run Once)

Run the following command in the project root directory to activate the git hooks:

```bash
pre-commit install
```

*Output should be: `pre-commit installed at .git/hooks/pre-commit`*

#### Usage

- **Automatic:** Just run `git commit` as usual.
- If **Black** modifies your files: Run `git add .` again and re-commit.
- If **Flake8** reports errors: Fix the errors, `git add`, and re-commit.
- **Manual:** To check all files in the repository without committing:
```bash
pre-commit run --all-files
```

#### Skip Checks (Emergency Only)

If you need to bypass the checks for a specific commit:

```bash
git commit -m "your message" --no-verify
```

---

## Adding a New Adapter

Expand Down
Loading