fix security questions

This commit is contained in:
zyw_hw
2025-03-04 21:25:48 +08:00
parent e246621846
commit a4de8c9e13
3 changed files with 10 additions and 29 deletions

View File

@@ -373,14 +373,12 @@ class AutoProcessor:
return AutoImageProcessor.from_pretrained(
pretrained_model_name_or_path, trust_remote_code=trust_remote_code, **kwargs
)
except Exception: # pylint: disable=W0703
pass
raise ValueError(
f"Unrecognized processing class in {pretrained_model_name_or_path}. Can't instantiate a processor, a "
"tokenizer, an image processor for this model. Make sure the repository contains "
"the files of at least one of those processing classes."
)
except Exception as e: # pylint: disable=W0703
raise ValueError(
f"Unrecognized processing class in {pretrained_model_name_or_path}. "
f"Can't instantiate a processor, a tokenizer, an image processor for this model. "
f"Make sure the repository contains the files of at least one of those processing classes."
) from e
@staticmethod
def register(config_class, processor_class, exist_ok=False):

View File

@@ -21,6 +21,7 @@ import os
import psutil
from mindformers.utils.bit_array import BitArray
from mindformers.tools.logger import logger
def get_cann_workqueue_cores(device_id: int) -> list:
@@ -73,24 +74,6 @@ def mask_to_str(mask: BitArray) -> str:
return mask_str
def execute_cmd(cmd: str, fake: bool = True):
"""
execute shell command
Args:
cmd (`str`):
The command need to execute.
fake (`bool`, *optional*, defaults to `False`):
If fake execute is True, then print command instead to execute.
Returns:
NA.
"""
if fake:
print(cmd)
return
def binding_cann_workqueue(device_num: int, core_num_per_workqueue: int, separate_device_cores: bool):
"""
binding cann workqueue cores
@@ -126,7 +109,7 @@ def binding_cann_workqueue(device_num: int, core_num_per_workqueue: int, separat
if separate_device_cores:
mask_str = mask_to_str(mask)
bind_cann_core_cmd = f"echo \"{mask_str}\" > {cann_workqueue_config_path}"
execute_cmd(bind_cann_core_cmd)
logger.info(bind_cann_core_cmd)
if not separate_device_cores:
device_core_mask_str = mask_to_str(device_core_mask)
@@ -134,4 +117,4 @@ def binding_cann_workqueue(device_num: int, core_num_per_workqueue: int, separat
for i in range(device_num):
cann_workqueue_config_path = f"/sys/devices/virtual/workqueue/dev{i}_sq_send_wq/cpumask"
bind_cann_core_cmd = f"echo \"{device_core_mask_str}\" > {cann_workqueue_config_path}"
execute_cmd(bind_cann_core_cmd)
logger.info(bind_cann_core_cmd)

View File

@@ -78,7 +78,7 @@ def update_permissions(path):
for dirpath, dirnames, filenames in os.walk(path):
for dirname in dirnames:
dir_fullpath = os.path.join(dirpath, dirname)
os.chmod(dir_fullpath, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC | stat.S_IRGRP | stat.S_IXGRP)
os.chmod(dir_fullpath, stat.S_IREAD | stat.S_IEXEC)
for filename in filenames:
file_fullpath = os.path.join(dirpath, filename)
os.chmod(file_fullpath, stat.S_IREAD)