Skip to content

Commit

Permalink
adjust additionalProperties usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ksbrar committed Aug 9, 2023
1 parent 09c08cc commit 561e929
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ludwig/config_validation/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_schema(model_type: str = MODEL_ECD):
"title": "model_options",
"description": "Settings for Ludwig configuration",
"required": required,
"additionalProperties": True, # TODO: Set to false after 0.8 releases.
"additionalProperties": False, # TODO: May cause collision
}


Expand Down
1 change: 0 additions & 1 deletion ludwig/schema/features/augmentation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ def get_augmentation_list_jsonschema(feature_type: str, default: List[Dict[str,
"description": "Type of augmentation to apply.",
},
},
"additionalProperties": True,
"allOf": get_augmentation_list_conds(feature_type),
"required": ["type"],
},
Expand Down
2 changes: 1 addition & 1 deletion ludwig/schema/features/preprocessing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _jsonschema_type_mapping(self):
"type": "object",
"properties": props,
"title": "preprocessing_options",
"additionalProperties": True,
"additionalProperties": False, # TODO: May cause collision
}

try:
Expand Down
2 changes: 0 additions & 2 deletions ludwig/schema/features/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def get_input_feature_jsonschema(model_type: str):
},
"column": {"type": "string", "title": "column", "description": "Name of the column."},
},
"additionalProperties": True,
"allOf": get_input_feature_conds(model_type),
"required": ["name", "type"],
"title": "input_feature",
Expand Down Expand Up @@ -126,7 +125,6 @@ def get_output_feature_jsonschema(model_type: str):
},
"column": {"type": "string", "title": "column", "description": "Name of the column."},
},
"additionalProperties": True,
"allOf": get_output_feature_conds(model_type),
"required": ["name", "type"],
"title": "output_feature",
Expand Down
4 changes: 0 additions & 4 deletions ludwig/schema/model_types/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ def from_dict(config: ModelConfigDict) -> "ModelConfig":
# have `additionalProperties=False`, does not.
#
# Illustrative example: test_validate_config_misc.py::test_validate_no_trainer_type
#
# TODO: Set `additionalProperties=False` for all Ludwig schema, and look into passing in `unknown='RAISE'` to
# marshmallow.load(), which raises an error for unknown fields during deserialization.
# https://marshmallow.readthedocs.io/en/stable/marshmallow.schema.html#marshmallow.schema.Schema.load
check_schema(config)

cls = model_type_schema_registry[model_type]
Expand Down
4 changes: 2 additions & 2 deletions ludwig/schema/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def assert_is_a_marshmallow_class(cls):


@DeveloperAPI
def unload_jsonschema_from_marshmallow_class(mclass, additional_properties: bool = True, title: str = None) -> TDict:
def unload_jsonschema_from_marshmallow_class(mclass, additional_properties: bool = False, title: str = None) -> TDict:
"""Helper method to directly get a marshmallow class's JSON schema without extra wrapping props."""
assert_is_a_marshmallow_class(mclass)
schema = js(props_ordered=True).dump(mclass.Schema())["definitions"][mclass.__name__]
Expand All @@ -236,7 +236,7 @@ def unload_jsonschema_from_marshmallow_class(mclass, additional_properties: bool
prop_schema = schema["properties"][prop]
if "parameter_metadata" in prop_schema:
prop_schema["parameter_metadata"] = copy.deepcopy(prop_schema["parameter_metadata"])
schema["additionalProperties"] = additional_properties
schema["additionalProperties"] = additional_properties # TODO: May cause collision
if title is not None:
schema["title"] = title
return schema
Expand Down

0 comments on commit 561e929

Please sign in to comment.