Skip to content

Commit 1fb60ef

Browse files
committed
lint issue fix
1 parent af58d12 commit 1fb60ef

File tree

3 files changed

+53
-44
lines changed

3 files changed

+53
-44
lines changed

Diff for: setup.py

+50-43
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717
# limitations under the License.
1818
#
1919

20-
import os
21-
from typing import List, Dict
20+
import glob
2221
import importlib.util
22+
import logging
23+
import os
24+
import subprocess
25+
import sys
26+
from pathlib import Path
2327
from sysconfig import get_paths
28+
from typing import Dict, List
2429

2530
from setuptools import Extension, find_packages, setup
2631
from setuptools.command.build_ext import build_ext
2732
from setuptools.command.install import install
2833
from setuptools_scm import get_version
29-
import logging
30-
import sys
31-
import subprocess
32-
from pathlib import Path
33-
import glob
3434

3535

3636
def load_module_from_path(module_name, path):
@@ -45,15 +45,13 @@ def load_module_from_path(module_name, path):
4545
logger = logging.getLogger(__name__)
4646

4747

48-
def check_or_set_default_env(cmake_args,
49-
env_name,
50-
env_variable,
51-
default_path=""):
48+
def check_or_set_default_env(cmake_args, env_name, env_variable, default_path=""):
5249
if env_variable is None:
5350
logging.warning(
5451
f"No {env_name} found in your environment, pleause try to set {env_name} "
5552
"if you customize the installation path of this library, otherwise default "
56-
"path will be adapted during build this project")
53+
"path will be adapted during build this project"
54+
)
5755
logging.warning(f"Set default {env_name}: {default_path}")
5856
env_variable = default_path
5957
else:
@@ -65,13 +63,12 @@ def check_or_set_default_env(cmake_args,
6563
return cmake_args
6664

6765

68-
envs = load_module_from_path('envs',
69-
os.path.join(ROOT_DIR, 'vllm_ascend', 'envs.py'))
66+
envs = load_module_from_path("envs", os.path.join(ROOT_DIR, "vllm_ascend", "envs.py"))
7067

7168

7269
class CMakeExtension(Extension):
7370

74-
def __init__(self, name: str, cmake_lists_dir: str = '.', **kwa) -> None:
71+
def __init__(self, name: str, cmake_lists_dir: str = ".", **kwa) -> None:
7572
super().__init__(name, sources=[], py_limited_api=True, **kwa)
7673
self.cmake_lists_dir = os.path.abspath(cmake_lists_dir)
7774

@@ -113,9 +110,9 @@ def configure(self, ext: CMakeExtension) -> None:
113110
# Default use release mode to compile the csrc code
114111
# Turbo now support compiled with Release, Debug and RelWithDebugInfo
115112
if envs.CMAKE_BUILD_TYPE is None or envs.CMAKE_BUILD_TYPE not in [
116-
"Debug",
117-
"Release",
118-
"RelWithDebugInfo",
113+
"Debug",
114+
"Release",
115+
"RelWithDebugInfo",
119116
]:
120117
envs.CMAKE_BUILD_TYPE = "Release"
121118
cmake_args += [f"-DCMAKE_BUILD_TYPE={envs.CMAKE_BUILD_TYPE}"]
@@ -133,32 +130,36 @@ def configure(self, ext: CMakeExtension) -> None:
133130
)
134131

135132
# find PYTHON_EXECUTABLE
136-
check_or_set_default_env(cmake_args, "PYTHON_EXECUTABLE",
137-
sys.executable)
133+
check_or_set_default_env(cmake_args, "PYTHON_EXECUTABLE", sys.executable)
138134

139135
# find PYTHON_INCLUDE_PATH
140-
check_or_set_default_env(cmake_args, "PYHTON_INCLUDE_PATH",
141-
get_paths()["include"])
136+
check_or_set_default_env(
137+
cmake_args, "PYHTON_INCLUDE_PATH", get_paths()["include"]
138+
)
142139

143140
# ccache and ninja can not be applied at ascendc kernels now
144141

145142
try:
146143
# if pybind11 is installed via pip
147-
pybind11_cmake_path = (subprocess.check_output(
148-
[python_executable, "-m", "pybind11",
149-
"--cmake"]).decode().strip())
144+
pybind11_cmake_path = (
145+
subprocess.check_output(
146+
[python_executable, "-m", "pybind11", "--cmake"]
147+
)
148+
.decode()
149+
.strip()
150+
)
150151
except subprocess.CalledProcessError as e:
151152
# else specify pybind11 path installed from source code on CI container
152153
raise RuntimeError(f"CMake configuration failed: {e}")
153154

154155
# try retrive soc version from npu-smi
155156
soc_command = [
156-
"bash", "-c",
157-
"npu-smi info | grep OK | awk '{print $3}' | head -n 1"
157+
"bash",
158+
"-c",
159+
"npu-smi info | grep OK | awk '{print $3}' | head -n 1",
158160
]
159161
try:
160-
soc_version = subprocess.check_output(soc_command,
161-
text=True).strip()
162+
soc_version = subprocess.check_output(soc_command, text=True).strip()
162163
soc_version = "Ascend" + soc_version
163164
except subprocess.CalledProcessError as e:
164165
raise RuntimeError(f"Retrive Soc version failed: {e}")
@@ -176,7 +177,7 @@ def configure(self, ext: CMakeExtension) -> None:
176177
# To override this, set the FETCHCONTENT_BASE_DIR environment variable.
177178
fc_base_dir = os.path.join(ROOT_DIR, ".deps")
178179
fc_base_dir = os.environ.get("FETCHCONTENT_BASE_DIR", fc_base_dir)
179-
cmake_args += ['-DFETCHCONTENT_BASE_DIR={}'.format(fc_base_dir)]
180+
cmake_args += ["-DFETCHCONTENT_BASE_DIR={}".format(fc_base_dir)]
180181

181182
build_tool = []
182183
# TODO(ganyi): ninja and ccache support for ascend c auto codegen. now we can only use make build
@@ -192,15 +193,16 @@ def configure(self, ext: CMakeExtension) -> None:
192193
raise RuntimeError(f"CMake configuration failed: {e}")
193194

194195
subprocess.check_call(
195-
['cmake', ext.cmake_lists_dir, *build_tool, *cmake_args],
196-
cwd=self.build_temp)
196+
["cmake", ext.cmake_lists_dir, *build_tool, *cmake_args],
197+
cwd=self.build_temp,
198+
)
197199

198200
def build_extensions(self) -> None:
199201
# Ensure that CMake is present and working
200202
try:
201-
subprocess.check_output(['cmake', '--version'])
203+
subprocess.check_output(["cmake", "--version"])
202204
except OSError as e:
203-
raise RuntimeError(f'Cannot find CMake executable: {e}')
205+
raise RuntimeError(f"Cannot find CMake executable: {e}")
204206

205207
# Create build directory if it does not exist.
206208
if not os.path.exists(self.build_temp):
@@ -231,7 +233,7 @@ def target_name(s: str) -> str:
231233
try:
232234
subprocess.check_call(["cmake", *build_args], cwd=self.build_temp)
233235
except OSError as e:
234-
raise RuntimeError(f'Build library failed: {e}')
236+
raise RuntimeError(f"Build library failed: {e}")
235237
# Install the libraries
236238
for ext in self.extensions:
237239
# Install the extension into the proper location
@@ -247,13 +249,18 @@ def target_name(s: str) -> str:
247249
# CMake, this is currently true for current extensions but may not
248250
# always be the case.
249251
prefix = outdir
250-
if '.' in ext.name:
252+
if "." in ext.name:
251253
prefix = prefix.parent
252254

253255
# prefix here should actually be the same for all components
254256
install_args = [
255-
"cmake", "--install", ".", "--prefix", prefix, "--component",
256-
target_name(ext.name)
257+
"cmake",
258+
"--install",
259+
".",
260+
"--prefix",
261+
prefix,
262+
"--component",
263+
target_name(ext.name),
257264
]
258265
subprocess.check_call(install_args, cwd=self.build_temp)
259266

@@ -331,7 +338,7 @@ def _read_requirements(filename: str) -> List[str]:
331338
cmdclass = {"build_ext": cmake_build_ext, "install": custom_install}
332339

333340
setup(
334-
name='vllm_ascend',
341+
name="vllm_ascend",
335342
# Follow:
336343
# https://packaging.python.org/en/latest/specifications/version-specifiers
337344
version=VERSION,
@@ -363,7 +370,7 @@ def _read_requirements(filename: str) -> List[str]:
363370
cmdclass=cmdclass,
364371
extras_require={},
365372
entry_points={
366-
'vllm.platform_plugins': ["ascend = vllm_ascend:register"],
367-
'vllm.general_plugins':
368-
["ascend_enhanced_model = vllm_ascend:register_model"]
369-
})
373+
"vllm.platform_plugins": ["ascend = vllm_ascend:register"],
374+
"vllm.general_plugins": ["ascend_enhanced_model = vllm_ascend:register_model"],
375+
},
376+
)

Diff for: tests/ops/test_rotary_embedding.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import torch_npu # noqa: F401
1212
from vllm.model_executor.layers.rotary_embedding import get_rope
1313
from vllm.platforms import current_platform
14+
1415
import vllm_ascend.platform # noqa: F401
1516

1617
# Only Neox style true scenario is supported for now

Diff for: vllm_ascend/platform.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
# limitations under the License.
1616
#
1717

18+
import logging
1819
import os
1920
from typing import TYPE_CHECKING, Optional, Tuple
20-
import logging
2121

2222
import torch
2323
import torch_npu # noqa: F401
2424
import vllm.envs as envs
2525
from vllm.config import CompilationLevel, VllmConfig
2626
from vllm.logger import init_logger
27+
2728
try:
2829
# register custom ops into torch_library here
2930
import vllm_ascend.vllm_ascend_C # noqa: F401

0 commit comments

Comments
 (0)