Skip to content
Merged
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
4 changes: 2 additions & 2 deletions runtime/python/onnxruntime/funasr_onnx/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ def __init__(self, model_file, device_id=-1, intra_op_num_threads=4):
RuntimeWarning,
)

def __call__(self, input_content: List[Union[np.ndarray, np.ndarray]]) -> np.ndarray:
def __call__(self, input_content: List[Union[np.ndarray, np.ndarray]], run_options = None) -> np.ndarray:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with other parameters and to improve code clarity, please add a type hint for the new run_options parameter. Using Any is appropriate here, as it's already imported from typing. This also ensures the code conforms to PEP 8 style for annotated function parameters.1

Style Guide References

Suggested change
def __call__(self, input_content: List[Union[np.ndarray, np.ndarray]], run_options = None) -> np.ndarray:
def __call__(self, input_content: List[Union[np.ndarray, np.ndarray]], run_options: Any = None) -> np.ndarray:

Footnotes

  1. PEP 8 specifies that for function parameters with annotations, there should be spaces around the = for default values (e.g., param: type = None). For unannotated parameters, there should be no spaces (e.g., param=None). Adding the type hint makes the code style consistent and correct.

input_dict = dict(zip(self.get_input_names(), input_content))
try:
return self.session.run(self.get_output_names(), input_dict)
return self.session.run(self.get_output_names(), input_dict, run_options)
except Exception as e:
raise ONNXRuntimeError("ONNXRuntime inferece failed.") from e

Expand Down