Fix none-comparison (E711) warnings (#19745)
Signed-off-by: Xiaodong Ye <yeahdongcn@gmail.com>
This commit is contained in:
@@ -86,7 +86,7 @@ class CustomAsyncHTTPXClient(httpx.AsyncClient):
|
|||||||
|
|
||||||
def get_client(provider):
|
def get_client(provider):
|
||||||
if provider not in "b10":
|
if provider not in "b10":
|
||||||
if os.getenv("OPENAI_API_KEY") == None:
|
if os.getenv("OPENAI_API_KEY") is None:
|
||||||
os.environ["OPENAI_API_KEY"] = "EMPTY"
|
os.environ["OPENAI_API_KEY"] = "EMPTY"
|
||||||
return {
|
return {
|
||||||
"oai": AsyncOpenAI(base_url="http://127.0.0.1:8000/v1/"),
|
"oai": AsyncOpenAI(base_url="http://127.0.0.1:8000/v1/"),
|
||||||
|
|||||||
+5
-5
@@ -1321,7 +1321,7 @@ def _nvmlGetFunctionPointer(name):
|
|||||||
libLoadLock.acquire()
|
libLoadLock.acquire()
|
||||||
try:
|
try:
|
||||||
# ensure library was loaded
|
# ensure library was loaded
|
||||||
if nvmlLib == None:
|
if nvmlLib is None:
|
||||||
raise NVMLError(NVML_ERROR_UNINITIALIZED)
|
raise NVMLError(NVML_ERROR_UNINITIALIZED)
|
||||||
try:
|
try:
|
||||||
_nvmlGetFunctionPointer_cache[name] = getattr(nvmlLib, name)
|
_nvmlGetFunctionPointer_cache[name] = getattr(nvmlLib, name)
|
||||||
@@ -1629,7 +1629,7 @@ class nvmlClkMonStatus_t(Structure):
|
|||||||
# On Windows with the WDDM driver, usedGpuMemory is reported as None
|
# On Windows with the WDDM driver, usedGpuMemory is reported as None
|
||||||
# Code that processes this structure should check for None, I.E.
|
# Code that processes this structure should check for None, I.E.
|
||||||
#
|
#
|
||||||
# if (info.usedGpuMemory == None):
|
# if (info.usedGpuMemory is None):
|
||||||
# # TODO handle the error
|
# # TODO handle the error
|
||||||
# pass
|
# pass
|
||||||
# else:
|
# else:
|
||||||
@@ -2870,13 +2870,13 @@ def _LoadNvmlLibrary():
|
|||||||
"""
|
"""
|
||||||
global nvmlLib
|
global nvmlLib
|
||||||
|
|
||||||
if nvmlLib == None:
|
if nvmlLib is None:
|
||||||
# lock to ensure only one caller loads the library
|
# lock to ensure only one caller loads the library
|
||||||
libLoadLock.acquire()
|
libLoadLock.acquire()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# ensure the library still isn't loaded
|
# ensure the library still isn't loaded
|
||||||
if nvmlLib == None:
|
if nvmlLib is None:
|
||||||
try:
|
try:
|
||||||
if sys.platform[:3] == "win":
|
if sys.platform[:3] == "win":
|
||||||
# cdecl calling convention
|
# cdecl calling convention
|
||||||
@@ -2902,7 +2902,7 @@ def _LoadNvmlLibrary():
|
|||||||
nvmlLib = CDLL("libnvidia-ml.so.1")
|
nvmlLib = CDLL("libnvidia-ml.so.1")
|
||||||
except OSError as ose:
|
except OSError as ose:
|
||||||
_nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
|
_nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
|
||||||
if nvmlLib == None:
|
if nvmlLib is None:
|
||||||
_nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
|
_nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
|
||||||
finally:
|
finally:
|
||||||
# lock is always freed
|
# lock is always freed
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ class MambaPool:
|
|||||||
|
|
||||||
def fork_from(self, src_index: torch.Tensor) -> Optional[torch.Tensor]:
|
def fork_from(self, src_index: torch.Tensor) -> Optional[torch.Tensor]:
|
||||||
dst_index = self.alloc(1)
|
dst_index = self.alloc(1)
|
||||||
if dst_index == None:
|
if dst_index is None:
|
||||||
return None
|
return None
|
||||||
self.copy_from(src_index, dst_index)
|
self.copy_from(src_index, dst_index)
|
||||||
return dst_index
|
return dst_index
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class TestNixlUnified(unittest.TestCase):
|
|||||||
|
|
||||||
# Test get
|
# Test get
|
||||||
retrieved2 = self.hicache.get(key, dst_addr, dst_len)
|
retrieved2 = self.hicache.get(key, dst_addr, dst_len)
|
||||||
self.assertTrue(retrieved2 == None)
|
self.assertTrue(retrieved2 is None)
|
||||||
self.verify_tensors_equal(value, dst_tensor2)
|
self.verify_tensors_equal(value, dst_tensor2)
|
||||||
|
|
||||||
def test_batch_set_get(self):
|
def test_batch_set_get(self):
|
||||||
@@ -159,7 +159,7 @@ class TestNixlUnified(unittest.TestCase):
|
|||||||
|
|
||||||
# Test batch get
|
# Test batch get
|
||||||
retrieved2 = self.hicache.batch_get(keys, dst_addrs, dst_lens)
|
retrieved2 = self.hicache.batch_get(keys, dst_addrs, dst_lens)
|
||||||
self.assertTrue(all(ret == None for ret in retrieved2))
|
self.assertTrue(all(ret is None for ret in retrieved2))
|
||||||
self.verify_tensor_lists_equal(values, dst_tensors2)
|
self.verify_tensor_lists_equal(values, dst_tensors2)
|
||||||
|
|
||||||
def test_mixed_operations(self):
|
def test_mixed_operations(self):
|
||||||
|
|||||||
@@ -2065,12 +2065,12 @@ def get_device(device_id: Optional[int] = None) -> str:
|
|||||||
return "cuda:{}".format(device_id)
|
return "cuda:{}".format(device_id)
|
||||||
|
|
||||||
if hasattr(torch, "xpu") and torch.xpu.is_available():
|
if hasattr(torch, "xpu") and torch.xpu.is_available():
|
||||||
if device_id == None:
|
if device_id is None:
|
||||||
return "xpu"
|
return "xpu"
|
||||||
return "xpu:{}".format(device_id)
|
return "xpu:{}".format(device_id)
|
||||||
|
|
||||||
if is_npu():
|
if is_npu():
|
||||||
if device_id == None:
|
if device_id is None:
|
||||||
return "npu"
|
return "npu"
|
||||||
return "npu:{}".format(device_id)
|
return "npu:{}".format(device_id)
|
||||||
|
|
||||||
@@ -2079,16 +2079,16 @@ def get_device(device_id: Optional[int] = None) -> str:
|
|||||||
import habana_frameworks.torch.hpu # noqa: F401
|
import habana_frameworks.torch.hpu # noqa: F401
|
||||||
|
|
||||||
if torch.hpu.is_available():
|
if torch.hpu.is_available():
|
||||||
if device_id == None:
|
if device_id is None:
|
||||||
return "hpu"
|
return "hpu"
|
||||||
return "hpu:{}".format(device_id)
|
return "hpu:{}".format(device_id)
|
||||||
except ImportError as e:
|
except ImportError:
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"Habana frameworks detected, but failed to import 'habana_frameworks.torch.hpu'."
|
"Habana frameworks detected, but failed to import 'habana_frameworks.torch.hpu'."
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_musa():
|
if is_musa():
|
||||||
if device_id == None:
|
if device_id is None:
|
||||||
return "musa"
|
return "musa"
|
||||||
return "musa:{}".format(device_id)
|
return "musa:{}".format(device_id)
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ def rpd_to_chrome_trace(
|
|||||||
rangeStringMonitor = ""
|
rangeStringMonitor = ""
|
||||||
min_time = connection.execute("select MIN(start) from rocpd_api;").fetchall()[0][0]
|
min_time = connection.execute("select MIN(start) from rocpd_api;").fetchall()[0][0]
|
||||||
max_time = connection.execute("select MAX(end) from rocpd_api;").fetchall()[0][0]
|
max_time = connection.execute("select MAX(end) from rocpd_api;").fetchall()[0][0]
|
||||||
if min_time == None:
|
if min_time is None:
|
||||||
raise Exception("Trace file is empty.")
|
raise Exception("Trace file is empty.")
|
||||||
|
|
||||||
print("Timestamps:")
|
print("Timestamps:")
|
||||||
|
|||||||
Reference in New Issue
Block a user