forked from microsoft/promptflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Internal][Executor] Add error target for batch engine error (microso…
…ft#1380) # Description Add error target for batch engine error # All Promptflow Contribution checklist: - [x] **The pull request does not introduce [breaking changes].** - [ ] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [x] **I have read the [contribution guidelines](../CONTRIBUTING.md).** - [ ] **Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: [suggested workflow](../CONTRIBUTING.md#suggested-workflow).** ## General Guidelines and Best Practices - [x] Title of the pull request is clear and informative. - [x] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### Testing Guidelines - [x] Pull request includes test coverage for the included changes.
- Loading branch information
1 parent
72703dd
commit 6cc2bcb
Showing
3 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/promptflow/tests/executor/unittests/batch/test_batch_engine.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from pathlib import Path | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from promptflow._core._errors import UnexpectedError | ||
from promptflow.batch import BatchEngine | ||
from promptflow.exceptions import ErrorTarget | ||
|
||
from ...utils import get_yaml_file | ||
|
||
|
||
@pytest.mark.unittest | ||
class TestBatchEngine: | ||
def test_batch_engine_error(self): | ||
with pytest.raises(UnexpectedError) as e: | ||
with patch( | ||
"promptflow.batch._batch_inputs_processor.BatchInputsProcessor.process_batch_inputs" | ||
) as mock_func: | ||
mock_func.side_effect = Exception("test error") | ||
batch_engine = BatchEngine(get_yaml_file("csharp_flow")) | ||
batch_engine.run({}, {}, Path(".")) | ||
assert e.value.target == ErrorTarget.BATCH | ||
assert isinstance(e.value.inner_exception, Exception) | ||
assert e.value.error_codes == ["SystemError", "UnexpectedError"] | ||
assert ( | ||
e.value.message == "Unexpected error occurred while executing the batch run. Error: (Exception) test error." | ||
) |