Skip to content

Commit

Permalink
refactor to decrease number of workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
baptistecolle committed Oct 14, 2024
1 parent b273a08 commit be34484
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 25 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_cpu_ipex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -s -k "cpu and ipex"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_cpu_llama_cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -s -k "cpu and llama_cpp"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_cpu_neural_compressor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -s -k "cpu and neural_compressor"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_cpu_onnxruntime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -s -k "cpu and onnxruntime"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_cpu_openvino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -s -k "cpu and openvino"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_cpu_py_txi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -s -k "examples and cpu and py_txi"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
11 changes: 8 additions & 3 deletions .github/workflows/test_cli_cpu_pytorch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -s -k "cpu and pytorch"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}


EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_cuda_onnxruntime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -x -s -k "cuda and onnxruntime"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
9 changes: 7 additions & 2 deletions .github/workflows/test_cli_cuda_py_txi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -x -s -k "cuda and py_txi"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}

EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_cuda_pytorch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,10 @@ jobs:
- name: Run test from example folder
run: |
pytest tests/test_examples.py -x -s -k "cuda and pytorch"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_cuda_tensorrt_llm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -x -s -k "cuda and tensorrt_llm"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_cuda_torch_ort.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -x -s -k "cuda and torch_ort"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_cuda_vllm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -x -s -k "cuda and vllm"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples_folder.py -s -k "examples and not (cpu or cuda or rocm or mps)"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
8 changes: 7 additions & 1 deletion .github/workflows/test_cli_rocm_pytorch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,10 @@ jobs:
- name: Run tests from example folder
run: |
pytest tests/test_examples.py -x -s -k "cuda and pytorch"
continue-on-error: ${{ failure() && steps.run.outcome == 'failure' && steps.run.exit_code == 5 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 5 ]; then
echo "No tests were collected. Skipping failure..."
exit 0
else
exit $EXIT_CODE
fi
15 changes: 8 additions & 7 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
]

CUDA_PYTORCH_SCRIPTS = [
"examples/pytorch_bert.py",
"examples/pytorch_llama.py",
"pytorch_bert.py",
"pytorch_llama.py",
]

ALL_YAML_CONFIGS = (
Expand Down Expand Up @@ -128,9 +128,10 @@ def test_yaml_config(config_name):
assert len(output_files) > 0, f"No output files found for {config_name}"


def execute_python_script(script_path):
def execute_python_script(script_name):
script_path = EXAMPLES_DIR / script_name
# Run the example file as a separate process
result = subprocess.run([sys.executable, script_path], capture_output=True, text=True)
result = subprocess.run([sys.executable, str(script_path)], capture_output=True, text=True)

# Check that the process completed successfully (return code 0)
assert result.returncode == 0, f"Script {script_path} failed with error:\n{result.stderr}"
Expand Down Expand Up @@ -189,6 +190,6 @@ def test_cuda_vllm_configs(config_name):
test_yaml_config(config_name)


@pytest.mark.parametrize("script_path", CUDA_PYTORCH_SCRIPTS)
def test_cuda_pytorch_scripts(script_path):
execute_python_script(script_path)
@pytest.mark.parametrize("script_name", CUDA_PYTORCH_SCRIPTS)
def test_cuda_pytorch_scripts(script_name):
execute_python_script(script_name)

0 comments on commit be34484

Please sign in to comment.