Closed arthurvd closed 2 years ago
This occurs because partitionFile
occurs twice:
PartitionFile = # Domain partition polygon file *_part.pol for parallel run
AngLat = 0. # Angle of latitude S-N (deg), 0: no Coriolis
AngLon = 0. # Angle of longitude E-W (deg), 0: Greenwich, used in solar heat flux computation.
Conveyance2D = -1 # -1: R=HU,0: R=H, 1: R=A/P, 2: K=analytic-1D conv, 3: K=analytic-2D conv
Slotw2D = 0. # -
NonLin1D = 0
1D2DLinkFile = # File containing the custom parameterization of 1D-2D links.
PartitionFile = # *_part.pol, polyline(s) x,y
Correct diagnosis.
I wonder how we can improve on the error message. The **data contains a list value for the duplicate input (often [None, None]
if both were empty), but it depends on the Field's datatype what kind of validation error is given.
For example for this field:
waterlevinifile: Optional[Path] = Field(None, alias="waterLevIniFile")
the error when passing duplicate lines in input is:
geometry -> waterLevIniFile
value is not a valid path (type=type_error.path)
When doing the same for a model class type, e.g.:
crosslocfile: Optional[CrossLocModel] = Field(None, alias="crossLocFile")
partitionfile: Optional[PolyFile] = Field(None, alias="partitionFile")
the error when passing duplicate lines in input is:
geometry -> crossLocFile
value is not a valid dict (type=type_error.dict)
geometry -> partitionFile
value is not a valid dict (type=type_error.dict)
Where can we catch this validation error and improve the message?
Duplicate of #92.
Describe the bug When reading an FMModel where the MDU contains empty partitionFile line, an incorrect validation error occurs ("not a valid dict").
To Reproduce
Read mdu model
fm = FMModel(modeldir / mdufile)
Exception has occurred: ValidationError 1 validation error for FMModel moergestels_broek.mdu -> geometry -> partitionFile value is not a valid dict (type=type_error.dict) File "C:\checkouts\HYDROLIB-core_git\hydrolib\core\basemodel.py", line 48, in init super().init(**data)
Possibly this originates from the fact that class PolyFile is involved, most other optional file fields are of type
Optional[Path]
Version info (please complete the following information):