-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CM-7772] llm add a proper asset upload error message for on prem bac…
…kend users (#34) * Implement check for on-prem in request exceptions handler * Fix lint errors * Refactor * Refactor request exception wrapper
- Loading branch information
1 parent
fe1f2ea
commit 40c0ed7
Showing
4 changed files
with
67 additions
and
21 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
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
39 changes: 30 additions & 9 deletions
39
tests/unit/experiment_api/test_request_exception_wrapper.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 |
---|---|---|
@@ -1,31 +1,52 @@ | ||
import pytest | ||
import requests | ||
from testix import * | ||
|
||
from comet_llm import exceptions | ||
from comet_llm.experiment_api import request_exception_wrapper | ||
|
||
|
||
def test_reraiser_no_exceptions(): | ||
@request_exception_wrapper.wrap | ||
@pytest.fixture(autouse=True) | ||
def mock_imports(patch_module): | ||
patch_module(request_exception_wrapper, "config") | ||
|
||
|
||
def test_wrap_no_exceptions(): | ||
@request_exception_wrapper.wrap() | ||
def f(): | ||
return "return-value" | ||
|
||
assert f() == "return-value" | ||
|
||
|
||
def test_reraiser__request_exception_caught__comet_exception_raised(): | ||
@request_exception_wrapper.wrap | ||
def test_wrap__request_exception_caught__comet_exception_raised(): | ||
@request_exception_wrapper.wrap() | ||
def f(): | ||
raise requests.RequestException | ||
|
||
with pytest.raises(exceptions.CometLLMException): | ||
f() | ||
|
||
|
||
def test_reraiser__generic_exception_not_caught(): | ||
@request_exception_wrapper.wrap | ||
def test_wrap__on_prem_check_enabled__request_exception_caught__on_prem_detected__comet_exception_raised_with_additional_message(): | ||
@request_exception_wrapper.wrap(check_on_prem=True) | ||
def f(): | ||
raise Exception | ||
raise requests.RequestException | ||
|
||
with Scenario() as s: | ||
s.config.comet_url() >> "https://not.comet.cloud/ddf/" | ||
with pytest.raises(exceptions.CometLLMException): | ||
f() | ||
|
||
|
||
def test_wrap__on_prem_check_enabled__request_exception_caught__on_prem_not_detected__comet_exception_raised_without_additional_message(): | ||
@request_exception_wrapper.wrap(check_on_prem=True) | ||
def f(): | ||
raise requests.RequestException | ||
|
||
COMET_CLOUD_URL = "https://www.comet.com/clientlib/" | ||
|
||
with pytest.raises(Exception): | ||
f() | ||
with Scenario() as s: | ||
s.config.comet_url() >> COMET_CLOUD_URL | ||
with pytest.raises(exceptions.CometLLMException): | ||
f() |