mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2025-01-09 21:54:27 +00:00
instantiate ValidationError according to https://github.com/pydantic/pydantic/issues/6734
This commit is contained in:
parent
ee35e5921b
commit
676d42d4f5
13 changed files with 130 additions and 39 deletions
|
@ -279,7 +279,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -288,8 +288,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
|
@ -524,7 +524,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -533,8 +533,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
|
@ -524,7 +524,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -533,8 +533,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
|
@ -524,7 +524,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -533,8 +533,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
||||||
|
|
||||||
if isinstance(model, dict):
|
if isinstance(model, dict):
|
||||||
for key, val in model.items():
|
for key, val in model.items():
|
||||||
if key in cls.model_fields:
|
if key in cls.model_fields or key in cls.NON_COLUMN_FIELDS:
|
||||||
continue
|
continue
|
||||||
if not isinstance(val, (VectorData, VectorIndex)):
|
if not isinstance(val, (VectorData, VectorIndex)):
|
||||||
try:
|
try:
|
||||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
||||||
else:
|
else:
|
||||||
model[key] = VectorData(name=key, description="", value=val)
|
model[key] = VectorData(name=key, description="", value=val)
|
||||||
except ValidationError as e: # pragma: no cover
|
except ValidationError as e: # pragma: no cover
|
||||||
raise ValidationError(
|
raise ValidationError.from_exception_data(
|
||||||
f"field {key} cannot be cast to VectorData from {val}"
|
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||||
|
line_errors=[
|
||||||
|
{
|
||||||
|
"type": "ValueError",
|
||||||
|
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||||
|
"input": val,
|
||||||
|
}
|
||||||
|
],
|
||||||
) from e
|
) from e
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue