-
Notifications
You must be signed in to change notification settings - Fork 45
Add ruff and isort #578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ruff and isort #578
Conversation
Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com>
6d45ee0
to
47a8063
Compare
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds ruff and isort as code linting and formatting tools to the project. The changes introduce comprehensive code style enforcement through configuration files and pre-commit hooks, while making extensive formatting changes throughout the codebase to conform to the new standards.
- Adds ruff and isort configuration in pyproject.toml with specific linting rules and import sorting settings
- Updates pre-commit configuration to include new linting and formatting hooks
- Applies extensive import reordering and code formatting across the entire codebase to meet new standards
Reviewed Changes
Copilot reviewed 96 out of 97 changed files in this pull request and generated 10 comments.
Show a summary per file
File | Description |
---|---|
pyproject.toml | Added comprehensive ruff and isort configuration settings |
.pre-commit-config.yaml | Added pre-commit hooks for ruff and isort, plus additional code quality checks |
test//test_.py | Reordered imports and applied formatting fixes across all test files |
auto_round/*.py | Applied import sorting and formatting changes to core library files |
auto_round_extension/*.py | Added copyright headers and formatting fixes to extension modules |
setup.py | Minor import reordering and code style improvements |
assert is_pure_text_model(model) | ||
|
||
def test_Qwen(self): | ||
model_name = "/models/Qwen2.5-7B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [28]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_phi4(self): | ||
model_name = "/models/phi-4" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [40]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_llama3(self): | ||
model_name = "/models/Meta-Llama-3.1-8B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_mixtral(self): | ||
model_name = "/models/Mixtral-8x7B-Instruct-v0.1" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use of bare assert statement without descriptive message. Consider adding a descriptive message for better debugging: assert is_pure_text_model(model), "Expected model to be pure text model"
Copilot uses AI. Check for mistakes.
assert is_pure_text_model(model) | ||
|
||
def test_Qwen(self): | ||
model_name = "/models/Qwen2.5-7B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [28]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_phi4(self): | ||
model_name = "/models/phi-4" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [40]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_llama3(self): | ||
model_name = "/models/Meta-Llama-3.1-8B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_mixtral(self): | ||
model_name = "/models/Mixtral-8x7B-Instruct-v0.1" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_falcon(self): | ||
model_name = "/models/Falcon3-7B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [28]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_orca(self): | ||
model_name = "/models/Orca-2-7b" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use of bare assert statement without descriptive message. Consider adding a descriptive message for better debugging: assert is_pure_text_model(model), "Expected model to be pure text model"
Copilot uses AI. Check for mistakes.
assert is_pure_text_model(model) | ||
|
||
def test_Qwen(self): | ||
model_name = "/models/Qwen2.5-7B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [28]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_phi4(self): | ||
model_name = "/models/phi-4" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [40]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_llama3(self): | ||
model_name = "/models/Meta-Llama-3.1-8B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_mixtral(self): | ||
model_name = "/models/Mixtral-8x7B-Instruct-v0.1" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_falcon(self): | ||
model_name = "/models/Falcon3-7B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [28]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_orca(self): | ||
model_name = "/models/Orca-2-7b" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_OLMo(self): | ||
model_name = "/models/OLMo-2-1124-7B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use of bare assert statement without descriptive message. Consider adding a descriptive message for better debugging: assert is_pure_text_model(model), "Expected model to be pure text model"
Copilot uses AI. Check for mistakes.
assert is_pure_text_model(model) | ||
|
||
def test_Qwen(self): | ||
model_name = "/models/Qwen2.5-7B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [28]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_phi4(self): | ||
model_name = "/models/phi-4" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [40]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_llama3(self): | ||
model_name = "/models/Meta-Llama-3.1-8B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_mixtral(self): | ||
model_name = "/models/Mixtral-8x7B-Instruct-v0.1" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_falcon(self): | ||
model_name = "/models/Falcon3-7B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [28]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_orca(self): | ||
model_name = "/models/Orca-2-7b" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) | ||
|
||
def test_OLMo(self): | ||
model_name = "/models/OLMo-2-1124-7B-Instruct" | ||
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True) | ||
block_names = get_block_names(model) | ||
self.check_block_names(block_names, ["model.layers"], [32]) | ||
assert is_pure_text_model(model) == True | ||
assert is_pure_text_model(model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use of bare assert statement without descriptive message. Consider adding a descriptive message for better debugging: assert is_pure_text_model(model), "Expected model to be pure text model"
Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add ruff and isort