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

bug: Set additionalProperties to True for preprocessing schemas. #2620

Merged
merged 4 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion ludwig/schema/features/preprocessing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _jsonschema_type_mapping():
"type": "object",
"properties": props,
"title": "preprocessing_options",
"additionalProperties": False,
"additionalProperties": True,
}

try:
Expand Down
2 changes: 1 addition & 1 deletion ludwig/schema/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get_preprocessing_jsonschema():
return {
"type": "object",
"properties": props,
"additionalProperties": False,
"additionalProperties": True,
"title": "global_preprocessing_options",
"description": "Select the preprocessing type.",
}
7 changes: 4 additions & 3 deletions tests/ludwig/schema/test_validate_config_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ def test_incorrect_input_features_config():
"output_features": [binary_feature()],
}

# Not a preprocessing param for category feature
with pytest.raises(ValidationError):
validate_config(config)
# TODO(ksbrar): Circle back after discussing whether additional properties should be allowed long-term.
# # Not a preprocessing param for category feature
# with pytest.raises(ValidationError):
# validate_config(config)

config = {
"input_features": [
Expand Down
43 changes: 22 additions & 21 deletions tests/ludwig/schema/test_validate_config_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,28 @@ def test_config_bad_encoder_name():
validate_config(config)


def test_config_bad_preprocessing_param():
config = {
"input_features": [
sequence_feature(encoder={"type": "parallel_cnn", "reduce_output": "sum"}),
image_feature(
"/tmp/destination_folder",
preprocessing={
"in_memory": True,
"height": 12,
"width": 12,
"num_channels": 3,
"tokenizer": "space",
},
),
],
"output_features": [category_feature(encoder={"vocab_size": 2}, reduce_input="sum")],
"combiner": {"type": "concat", "output_size": 14},
}

with pytest.raises(ValidationError, match=r"^Additional properties are not allowed .*"):
validate_config(config)
# TODO(ksbrar): Circle back after discussing whether additional properties should be allowed long-term.
# def test_config_bad_preprocessing_param():
# config = {
# "input_features": [
# sequence_feature(encoder={"type": "parallel_cnn", "reduce_output": "sum"}),
# image_feature(
# "/tmp/destination_folder",
# preprocessing={
# "in_memory": True,
# "height": 12,
# "width": 12,
# "num_channels": 3,
# "tokenizer": "space",
# },
# ),
# ],
# "output_features": [category_feature(encoder={"vocab_size": 2}, reduce_input="sum")],
# "combiner": {"type": "concat", "output_size": 14},
# }

# with pytest.raises(ValidationError, match=r"^Additional properties are not allowed .*"):
# validate_config(config)


def test_config_fill_values():
Expand Down
9 changes: 5 additions & 4 deletions tests/ludwig/schema/test_validate_config_preprocessing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pytest
# import pytest

from ludwig.schema import validate_config
from tests.integration_tests.utils import binary_feature, category_feature
Expand All @@ -22,7 +22,8 @@ def test_config_preprocessing():

validate_config(config)

config["preprocessing"]["fake_parameter"] = True
# TODO(ksbrar): Circle back after discussing whether additional properties should be allowed long-term.
# config["preprocessing"]["fake_parameter"] = True

with pytest.raises(Exception):
validate_config(config)
# with pytest.raises(Exception):
# validate_config(config)