Skip to content

Commit

Permalink
Extra test
Browse files Browse the repository at this point in the history
  • Loading branch information
achoum committed Nov 23, 2023
1 parent 99351da commit 8d1e02d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 3 additions & 1 deletion temporian/core/operators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ def check(self) -> None:
" inputs."
)

if available_input in [v.key for v in definition.inputs]:
if available_input in [
v.key for v in definition.inputs if v.HasField("key")
]:
if num_multi_input_matches != 0:
raise ValueError(
f'Input "{available_input}" matches both a prefix'
Expand Down
29 changes: 28 additions & 1 deletion temporian/core/test/operator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def build_fake_node():

t.check()

def test_check_operator_with_key_prefix_and_invalid_def(self):
def test_check_operator_error_overlapping_prefixes(self):
class ToyOperator(base.Operator):
@classmethod
def build_op_definition(cls) -> pb.OperatorDef:
Expand All @@ -127,6 +127,33 @@ def build_fake_node():
):
t.check()

def test_check_operator_error_overlapping_prefix_and_non_prefix(
self,
):
class ToyOperator(base.Operator):
@classmethod
def build_op_definition(cls) -> pb.OperatorDef:
return pb.OperatorDef(
key="TOY",
inputs=[
pb.OperatorDef.Input(key_prefix="input_"),
pb.OperatorDef.Input(key="input_1"),
],
)

def _get_pandas_implementation(self):
raise NotImplementedError()

def build_fake_node():
return input_node(features=[])

t = ToyOperator()
t.add_input("input_1", build_fake_node())
with self.assertRaisesRegex(
ValueError, "matches both a prefix and non-prefix input"
):
t.check()


if __name__ == "__main__":
absltest.main()

0 comments on commit 8d1e02d

Please sign in to comment.