huggingface / huggingface/optimum-intel

[Bug] Platform-specific code and hardcoded paths in test_ernie_image.py break tests on Windows

Open
#1,697 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
620
Forks
270
Avg merge
3d 10h
Merged PRs (30d)
22

Description

### Description
The newly added ERNIE-Image test script (`test_ernie_image.py`) contains a few platform-specific testing flaws that break cross-platform compatibility, particularly for Windows (which is a primary OpenVINO target):

1. **Unix-only subprocess commands:** The script uses `subprocess.run(["rm", "-rf", dir])` to clear output models. This will fail with a `FileNotFoundError/CommandNotFound` on Windows systems.
2. **Hardcoded Linux temp paths:** The default output directory is hardcoded to `/tmp/ernie_image_ov_test`, which is Unix-specific.
3. **Hardcoded developer paths:** The default `--model-path` is hardcoded to a developer's local home directory (`/home/ethan/intel/ERNIE-image/ERNIE-Image`), exposing personal directory structures and failing cleanly for any other user without manually overriding the argument.

### Expected Behavior
Test scripts in the repository should be fully cross-platform and rely on agnostic Python libraries (`tempfile`, `shutil`) rather than OS-specific CLI utilities, and should not contain hardcoded private paths.

### Proposed Solution
- Replace `rm -rf` subprocess calls with Python's cross-platform `shutil.rmtree()`.
- Replace the `/tmp/` default string with `tempfile.gettempdir()`.
- Remove the developer-specific default model path and mark the argument natively as `required=True`.

I would like to work on this issue and submit a PR to resolve cross-platform testing issues.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.