Skip to content
Open
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
12 changes: 6 additions & 6 deletions maxim/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from typing import Any, Dict, Optional

from ..models.dataset import (
ContextToEvaluateColumn,
CONTEXT_TO_EVALUATE_COLUMN,
DataStructure,
ExpectedOutputColumn,
InputColumn,
EXPECTED_OUTPUT_COLUMN,
INPUT_COLUMN,
)


Expand All @@ -20,23 +20,23 @@ def sanitize_data_structure(data_structure: Optional[DataStructure]) -> None:
encountered_context_to_evaluate = False
if data_structure:
for value in data_structure.values():
if value == InputColumn:
if value == INPUT_COLUMN:
if encountered_input:
raise Exception(
"Data structure contains more than one input",
{"dataStructure": json.dumps(data_structure, indent=2)},
)
else:
encountered_input = True
elif value == ExpectedOutputColumn:
elif value == EXPECTED_OUTPUT_COLUMN:
if encountered_expected_output:
raise Exception(
"Data structure contains more than one expectedOutput",
{"dataStructure": json.dumps(data_structure, indent=2)},
)
else:
encountered_expected_output = True
elif value == ContextToEvaluateColumn:
elif value == CONTEXT_TO_EVALUATE_COLUMN:
if encountered_context_to_evaluate:
raise Exception(
"Data structure contains more than one contextToEvaluate",
Expand Down
10 changes: 10 additions & 0 deletions maxim/models/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ def to_json(self):
return return_dict


# Column name constants used throughout the dataset utilities.
INPUT_COLUMN: str = "INPUT"
EXPECTED_OUTPUT_COLUMN: str = "EXPECTED_OUTPUT"
CONTEXT_TO_EVALUATE_COLUMN: str = "CONTEXT_TO_EVALUATE"
VARIABLE_COLUMN: str = "VARIABLE"
NULLABLE_VARIABLE_COLUMN: str = "NULLABLE_VARIABLE"
OUTPUT_COLUMN: str = "OUTPUT"

# Type aliases for column names. These are used for type checking but also
# need to be concrete values at runtime for equality comparisons.
InputColumn = Literal["INPUT"]
ExpectedOutputColumn = Literal["EXPECTED_OUTPUT"]
ContextToEvaluateColumn = Literal["CONTEXT_TO_EVALUATE"]
Expand Down