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

fix: Add back missing split fields #2848

Merged
merged 3 commits into from
Dec 16, 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/split.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def get_split_conds():
for splitter in split_config_registry.data:
splitter_cls = split_config_registry.data[splitter]
other_props = schema_utils.unload_jsonschema_from_marshmallow_class(splitter_cls)["properties"]
schema_utils.remove_duplicate_fields(other_props)
schema_utils.remove_duplicate_fields(other_props, TYPE)
splitter_cond = schema_utils.create_cond(
{"type": splitter},
other_props,
Expand Down
7 changes: 4 additions & 3 deletions ludwig/schema/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Any
from typing import Dict as TDict
from typing import List as TList
from typing import Tuple, Type, Union
from typing import Optional, Tuple, Type, Union

import yaml
from marshmallow import EXCLUDE, fields, schema, validate, ValidationError
Expand Down Expand Up @@ -103,7 +103,7 @@ def create_cond(if_pred: TDict, then_pred: TDict):


@DeveloperAPI
def remove_duplicate_fields(properties: dict) -> None:
def remove_duplicate_fields(properties: dict, fields: Optional[TList[str]] = None) -> None:
"""Util function for removing duplicated schema elements. For example, input feature json schema mapping has a
type param defined directly on the json schema, but also has a parameter defined on the schema class. We need
both -
Expand All @@ -114,7 +114,8 @@ def remove_duplicate_fields(properties: dict) -> None:
Args:
properties: Dictionary of properties generated from a Ludwig schema class
"""
for key in [NAME, TYPE, COLUMN, PROC_COLUMN, ACTIVE]: # TODO: Remove col/proc_col once train metadata decoupled
duplicate_fields = [NAME, TYPE, COLUMN, PROC_COLUMN, ACTIVE] if fields is None else fields
for key in duplicate_fields: # TODO: Remove col/proc_col once train metadata decoupled
if key in properties:
del properties[key]

Expand Down
3 changes: 0 additions & 3 deletions tests/ludwig/schema/test_validate_config_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,6 @@ def test_schema_no_duplicates():
assert field not in schema["properties"]["output_features"]["items"]["allOf"][0]["then"]["properties"]
assert field not in schema["properties"]["combiner"]["allOf"][0]["then"]["properties"]
assert field not in schema["properties"]["trainer"]["properties"]["optimizer"]["allOf"][0]["then"]["properties"]
assert (
field not in schema["properties"]["preprocessing"]["properties"]["split"]["allOf"][0]["then"]["properties"]
)
assert (
field
not in schema["properties"]["input_features"]["items"]["allOf"][0]["then"]["properties"]["encoder"][
Expand Down