mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2024-11-12 17:54:29 +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):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -288,8 +288,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
|
@ -524,7 +524,7 @@ class DynamicTableMixin(BaseModel):
|
|||
|
||||
if isinstance(model, dict):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -533,8 +533,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
|
@ -524,7 +524,7 @@ class DynamicTableMixin(BaseModel):
|
|||
|
||||
if isinstance(model, dict):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -533,8 +533,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
|
@ -524,7 +524,7 @@ class DynamicTableMixin(BaseModel):
|
|||
|
||||
if isinstance(model, dict):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -533,8 +533,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
|||
|
||||
if isinstance(model, dict):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
|||
|
||||
if isinstance(model, dict):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
|||
|
||||
if isinstance(model, dict):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
|||
|
||||
if isinstance(model, dict):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
|||
|
||||
if isinstance(model, dict):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
|||
|
||||
if isinstance(model, dict):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
|||
|
||||
if isinstance(model, dict):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
|||
|
||||
if isinstance(model, dict):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
|
@ -526,7 +526,7 @@ class DynamicTableMixin(BaseModel):
|
|||
|
||||
if isinstance(model, dict):
|
||||
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
|
||||
if not isinstance(val, (VectorData, VectorIndex)):
|
||||
try:
|
||||
|
@ -535,8 +535,15 @@ class DynamicTableMixin(BaseModel):
|
|||
else:
|
||||
model[key] = VectorData(name=key, description="", value=val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
raise ValidationError(
|
||||
f"field {key} cannot be cast to VectorData from {val}"
|
||||
raise ValidationError.from_exception_data(
|
||||
title=f"field {key} cannot be cast to VectorData from {val}",
|
||||
line_errors=[
|
||||
{
|
||||
"type": "ValueError",
|
||||
"loc": ("DynamicTableMixin", "cast_extra_columns"),
|
||||
"input": val,
|
||||
}
|
||||
],
|
||||
) from e
|
||||
return model
|
||||
|
||||
|
|
Loading…
Reference in a new issue