onnxruntime/tools/python/util
Jian Chen 6c2ff5fc55
Refactor emulator start and stop functions for clarity and efficiency (#22861)
### Description
This pull request introduces several enhancements and new
functionalities to the `tools/python/util/android/android.py` file,
focusing on improving the management of Android emulators. The most
important changes include adding a timeout parameter to the
`start_emulator` function, adding checks to prevent multiple emulators
from running simultaneously, and introducing new utility functions to
manage emulator processes more effectively.

Enhancements to `start_emulator` function:

* Added a `timeout_minutes` parameter to the `start_emulator` function
to make the startup timeout configurable.
[[1]](diffhunk://#diff-c54db556a9c445989f830c09ab90ce2704e648deaccce9c9e0ee4875ddaa864dL108-R117)
[[2]](diffhunk://#diff-c54db556a9c445989f830c09ab90ce2704e648deaccce9c9e0ee4875ddaa864dL158-R170)
* Added a check to prevent starting a new emulator if one with the same
AVD name is already running.
* Included additional emulator arguments `-verbose` for better control
and debugging.
* Added a final verification step to ensure the emulator has started
successfully.

New utility functions for managing emulator processes:

* Introduced `check_emulator_running_using_avd_name `,
`check_emulator_running_using_process`, and
`check_emulator_running_using_pid` to check if an emulator is running
based on AVD name, process instance, or PID, respectively.
* Added `stop_emulator_by_proc` and `stop_emulator_by_pid` functions to
stop the emulator process using a `subprocess.Popen` instance or PID,
with a configurable timeout.
* Updated the `stop_emulator` function to use the new utility functions
for stopping the emulator process.

These changes enhance the robustness and flexibility of the emulator
management utilities, making it easier to handle different scenarios in
CI environments and development workflows.



### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Scott McKay <skottmckay@gmail.com>
2024-12-02 09:29:17 -08:00
..
android Refactor emulator start and stop functions for clarity and efficiency (#22861) 2024-12-02 09:29:17 -08:00
mobile_helpers Fix usability checker CoreML config file path. (#21626) 2024-08-06 12:42:57 -07:00
ort_format_model Bump ruff to 0.3.2 and black to 24 (#19878) 2024-03-13 10:00:32 -07:00
qdq_helpers Graph transformer to ensure unique DQ nodes for QDQ node units (#15145) 2023-03-31 08:39:43 +10:00
test Adopt linrtunner as the linting tool - take 2 (#15085) 2023-03-24 15:29:03 -07:00
__init__.py Adopt linrtunner as the linting tool - take 2 (#15085) 2023-03-24 15:29:03 -07:00
__init__append.py Adopt linrtunner as the linting tool - take 2 (#15085) 2023-03-24 15:29:03 -07:00
add_openvino_win_libs.py Enable model subgraph execution in OVEP and setting the OpenVINO dll's to the path from the OpenVINO pypi packge in OVEP and fix OVEP windows io buffer sample (#16147) 2023-06-16 19:47:09 -07:00
check_onnx_model_mobile_usability.py Update to mobile model usability checker (#19843) 2024-06-18 07:50:33 +10:00
convert_onnx_models_to_ort.py Bump ruff to 0.3.2 and black to 24 (#19878) 2024-03-13 10:00:32 -07:00
file_utils.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
get_azcopy.py [Linter] Bump ruff and remove pylint (#17797) 2023-10-05 21:07:33 -07:00
logger.py Add tool to fix lines > 120 chars. (#18293) 2023-11-09 10:12:57 +10:00
make_dynamic_shape_fixed.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
onnx_model_utils.py Update to allow large models to be checked for mobile support. (#18357) 2023-11-17 07:20:16 +10:00
optimize_onnx_model.py Fix url in the code documentation (graph optimizations) (#16770) 2023-07-20 07:02:22 -07:00
platform_helpers.py Adopt linrtunner as the linting tool - take 2 (#15085) 2023-03-24 15:29:03 -07:00
pytorch_export_helpers.py Enable pylint and numpy rules (#15218) 2023-03-27 20:37:53 -07:00
reduced_build_config_parser.py Update ruff and clang-format versions (#21479) 2024-07-24 11:50:11 -07:00
run.py Adopt linrtunner as the linting tool - take 2 (#15085) 2023-03-24 15:29:03 -07:00
update_onnx_opset.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00