forked from caikit/caikit-nlp
-
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.
Merge pull request caikit#247 from dtrifiro/fix-uncaught-exception
fix uncaught exception in http client
- Loading branch information
Showing
2 changed files
with
49 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Third Party | ||
import pytest | ||
|
||
# First Party | ||
from caikit.core.data_model.producer import ProducerId | ||
from caikit.interfaces.nlp.data_model import GeneratedTextResult | ||
|
||
# Local | ||
from caikit_nlp.toolkit.text_generation.model_run_utils import generate_text_func | ||
from tests.fixtures import ( | ||
causal_lm_dummy_model, | ||
causal_lm_train_kwargs, | ||
seq2seq_lm_dummy_model, | ||
seq2seq_lm_train_kwargs, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"model_fixture", ["seq2seq_lm_dummy_model", "causal_lm_dummy_model"] | ||
) | ||
@pytest.mark.parametrize( | ||
"serialization_method,expected_type", | ||
[ | ||
("to_dict", dict), | ||
("to_json", str), | ||
("to_proto", GeneratedTextResult._proto_class), | ||
], | ||
) | ||
def test_generate_text_func_serialization_json( | ||
request, | ||
model_fixture, | ||
serialization_method, | ||
expected_type, | ||
): | ||
model = request.getfixturevalue(model_fixture) | ||
generated_text = generate_text_func( | ||
model=model.model, | ||
tokenizer=model.tokenizer, | ||
producer_id=ProducerId("TextGeneration", "0.1.0"), | ||
eos_token="<\n>", | ||
text="What is the boiling point of liquid Nitrogen?", | ||
) | ||
|
||
serialized = getattr(generated_text, serialization_method)() | ||
assert isinstance(serialized, expected_type) |