Parsing DFoundation files v21

Hi Support,
The DFoundation version on my computer has been updated to version v21.1. An application using DFoundation shows an error since then. The application is able to perform a DFoundation analysis with DFoundationAnalysis from viktor.external.dfoundations but the parsing of the *.fod file with OutputFileParser from viktor.external.dfoundations gives the following error msg (I suspect it is because the OutputFileParser is not compatible with the v21 version, but how to solve it?):

File "/usr/src/app/app/applib/use_cases/fill_geotechnical_databases.py", line 302, in get_calculation_result_for_tension_piles
parser_results_for_interval = OutputFileParser(StringIO(fod_file_for_interval.getvalue().decode('UTF-8')))
File "viktor/external/dfoundations.pyx", line 2403, in viktor.external.dfoundations.OutputFileParser.__new__
' is not (yet) implemented for version 21.el type '1: Tension Piles (EC7-NL)

Hi Bart,

You are right, the output from our SDK does not currently support D-Foundations v21 (SDK Reference - D-Foundations | VIKTOR Documentation)
The quickest fix would probably be to keep a backup version of DFoundations v19 on your computer if possible, until the parser is updated for the latest versions.
Parsing the file yourself always remains an option but that could be quite time consuming.

Is there an idea about when the adaptation of the OutputParser to DFoundation v21 is planned?

Hi Bart,

We will not be updating our D-series bindings to be compatible with newer versions as Deltares has developed and open-sourced the GEOLib (GitHub - Deltares/GEOLib: GEOLib: Python wrappers around the input and output files of the Deltares D-Serie models). This will be standard way to create and parse D-series files.

Currently, they state that they support version 19.1 (Setup — geolib 0.1.6 documentation). Furthermore, they say that there might be small differences with newer versions of the D-series software, but because it is open-source you could probably adjust the code yourself if you run into errors.

Hi,
I have been trying to implement the GEOLib package into our applications. The generating of the input file and the calculation via the worker works fine. Also the output file seems correct. However I can’t get the file parser working. Here is the code I use:

    file = File()
    path = Path(file.source)
    df.serialize(path)

    dfoundation_analysis = DFoundationsAnalysis(input_file=file)
    dfoundation_analysis.execute(timeout=600)

    temp_file = NamedTemporaryFile(
        suffix='.fod',
        delete=False,
        mode='wb',
    )
    temp_file.write(dfoundation_analysis.get_output_file('.fod').getvalue())
    path = Path(temp_file.name)

    parsed_file = df.parse(filename=path)
    temp_file.close()
    os.remove(temp_file.name)

I get the following error msg:

  File "/usr/src/app/app/applib/core_methods_and_classes/tension_piles_calculation.py", line 691, in geolibcalculation
    parsed_file = df.parse(filename=path)
  File "geolib/models/base_model.pyx", line 151, in geolib.models.base_model.BaseModel.parse
  File "geolib/models/parsers.pyx", line 61, in geolib.models.parsers.BaseParserProvider.parse
  File "geolib/models/dseries_parser.pyx", line 1146, in geolib.models.dseries_parser.DSerieParser.parse
  File "geolib/models/dseries_parser.pyx", line 1147, in geolib.models.dseries_parser.DSerieParser.parse
  File "geolib/models/dseries_parser.pyx", line 158, in geolib.models.dseries_parser.DSeriesStructure.parse_text
  File "geolib/models/dseries_parser.pyx", line 98, in geolib.models.dseries_parser.DSeriesStructure.__init__
  File "geolib/models/dseries_parser.pyx", line 158, in geolib.models.dseries_parser.DSeriesStructure.parse_text
  File "geolib/models/dseries_parser.pyx", line 98, in geolib.models.dseries_parser.DSeriesStructure.__init__
  File "geolib/models/dseries_parser.pyx", line 158, in geolib.models.dseries_parser.DSeriesStructure.parse_text
  File "geolib/models/dseries_parser.pyx", line 75, in geolib.models.dseries_parser.DSeriesStructure.__init__
ValueError: Got more fields than defined on model DFoundationsInputStructure:
                parser has {'user_classification_method'} fields and
                model has set() fields not set.

Is there something missing?

Hi @bart.vosslamber,

it’s a bit of a guess because i cannot see where you create df or what it is, but the object you call .parse() on should be a GeoLib DFoundationsModel, try using:

parsed_file = DFoundationsModel().parse(path)

So it’s basically as if you are creating a new model, only based on an .fod so your newly created model will also have results

Hi @rweigand,

I have changed the code to:

parsed_file = DFoundationsModel().parse(filename=path)

(DFoundationsModel imported from geolib)

Still the same error message remins:

  File "geolib/models/dseries_parser.pyx", line 158, in geolib.models.dseries_parser.DSeriesStructure.parse_text
  File "geolib/models/dseries_parser.pyx", line 75, in geolib.models.dseries_parser.DSeriesStructure.__init__
ValueError: Got more fields than defined on model DFoundationsInputStructure:
                parser has {'user_classification_method'} fields and
                model has set() fields not set.

Do you have another suggestion how to fix this?

Hi @bart.vosslamber,

Seems a bit strange to me, this error seems to say: there are fields with values in this file that i do not know how to handle (the user_classification_method), but i think that’s weird because (probably) this is the same input you used to create a GeoLib DFoundationsModel with in the first place no?

Maybe we are missing something here, and there is another explanation, but it could be a bug in GeoLib? In any case, i think this is so specific to their package that it’s probably best to ask your question to them directly, you can do so on their github page: Issues · Deltares/GEOLib · GitHub

In the mean time, I’ll ask if anyone here has any suggestions and get back to you if we come up with something.

Regards,

Roeland

hi @rweigand,

I have posted the question on GitHub.

In the .fod output file there is a section like this:

[USER CLASSIFICATION METHOD]
0
[END OF USER CLASSIFICATION METHOD]

If I delete this section, the file can be parsed correctly.

Hi @bart.vosslamber,

Good stuff, finding the issue and a workaround. Still seems a bit strange that there is a section in the .fod, which is based on a succesfully run .foi, that causes problems for the parser. I’ll follow your issue on the GeoLib gitlab with interest!

Regards,
Roeland