Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#124: Better error messages in case of missing parameters #148

Merged
merged 7 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def get_prediction_from_unique_param_based_dataframes(self, model_df) \
def _check_values_not_null(model_name, bucketfs_conn, sub_dir):
if not (model_name and bucketfs_conn and sub_dir):
error_message = f"For each model model_name, bucketfs_conn and sub_dir need to be provided. " \
f"Found model_name = {model_name}, bucketfs_conn = {bucketfs_conn}, sub_dir = {sub_dir}"
f"Found model_name = {model_name}, bucketfs_conn = {bucketfs_conn}, sub_dir = {sub_dir}."
raise ValueError(error_message)

@staticmethod
Expand Down
19 changes: 10 additions & 9 deletions tests/unit_tests/udfs/test_base_udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from tests.unit_tests.udfs.base_model_dummy_implementation import DummyImplementationUDF
from exasol_transformers_extension.utils.huggingface_hub_bucketfs_model_transfer import ModelFactoryProtocol
from tests.utils.mock_cast import mock_cast
import re


def create_mock_metadata() -> MockMetaData:
Expand Down Expand Up @@ -41,8 +42,8 @@ def udf_wrapper():
return meta


@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ,"
"sub_dir, model_name", [
@pytest.mark.parametrize(["description", "bucketfs_conn_name", "bucketfs_conn",
"sub_dir", "model_name"], [
("all given", "test_bucketfs_con_name", Connection(address=f"file:///test"),
"test_subdir", "test_model")
])
Expand Down Expand Up @@ -81,9 +82,9 @@ def test_model_downloader_all_parameters(description, bucketfs_conn_name, bucket
assert res[0][-1] is None and len(res[0]) == len(mock_meta.output_columns)


@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ,"
"sub_dir, model_name", [
("all null", '', None, None, None),
@pytest.mark.parametrize(["description", "bucketfs_conn_name", "bucketfs_conn",
"sub_dir", "model_name"], [
("all null", None, None, None, None),
("model name missing", "test_bucketfs_con_name", Connection(address=f"file:///test"),
"test_subdir", None),
("bucketfs_conn missing", None, None,
Expand Down Expand Up @@ -133,8 +134,8 @@ def test_model_downloader_missing_parameters(description, bucketfs_conn_name, bu
udf.run(mock_ctx)
res = mock_ctx.output
error_field = res[0][-1]
expected_error_start = f"For each model model_name, bucketfs_conn and sub_dir need to be provided. " \
f"Found model_name = {model_name},"
expected_error_end = f" sub_dir = {sub_dir}"
pattern = f"For each model model_name, bucketfs_conn and sub_dir need to be provided. Found model_name = " \
f"{model_name}, bucketfs_conn = .*, sub_dir = {sub_dir}."

assert re.search(pattern, error_field)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert error_field is not None and len(res[0]) == len(mock_meta.output_columns)
assert expected_error_start in error_field and expected_error_end in error_field
Loading