Skip to content

Commit 5ccbcf1

Browse files
committed
Task: Better errors on validation failure.
1 parent e34571a commit 5ccbcf1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

dp3/common/task.py

+3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def instanciate_dps(v, info: FieldValidationInfo):
8181

8282
# Fetch datapoint model
8383
context = info.context
84+
assert context is not None, "Missing context"
8485
assert context.get("model_spec"), "Missing `model_spec` in context"
8586
try:
8687
dp_model = context.get("model_spec").attr(etype, attr).dp_model
@@ -95,6 +96,8 @@ def instanciate_dps(v, info: FieldValidationInfo):
9596

9697

9798
def validate_data_points(v, info: FieldValidationInfo):
99+
if "etype" not in info.data or "eid" not in info.data:
100+
return v
98101
assert (
99102
v.etype == info.data["etype"]
100103
), f"Task's etype '{info.data['etype']}' doesn't match datapoint's etype '{v.etype}'"

0 commit comments

Comments
 (0)