Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove indents from mdu file #493

Closed
veenstrajelmer opened this issue Mar 30, 2023 · 5 comments · Fixed by #514
Closed

Remove indents from mdu file #493

veenstrajelmer opened this issue Mar 30, 2023 · 5 comments · Fixed by #514
Assignees
Labels
type: enhancement Improvements to existing functionality
Milestone

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Mar 30, 2023

Describe the bug
Indents are written in mdu file

To Reproduce

import hydrolib.core.dflowfm as hcdfm
file_mdu = 'with_optional_sections.mdu'
fm = hcdfm.FMModel(file_mdu)
fm.save('test.mdu')

Expected behavior
No indents

Screenshots

# written by HYDROLIB-core 0.4.1

[General]
    fileVersion           = 1.09           # File format version (do not edit this)
    fileType              = modelDef       # File type. Do not edit this.
    program               = D-Flow FM      # Program
    version               = 1.2.143.140737 # Version number of computational kernel
    autoStart             = 0              # Autostart simulation after loading MDU (0: no, 1: autostart, 2: autostartstop)
    pathsRelativeToParent = 0              # Default: 0. Whether or not (1/0) to resolve file names (e.g. inside the *.ext file) relative to their direct parent, instead of to the toplevel MDU working dir.

[Geometry]
    netFile                    =
    bathymetryFile             =        # Removed since March 2022. See [geometry] keyword BedLevelFile.
    dryPointsFile              =
    structureFile              =

Version info (please complete the following information):

  • Version: main branch

Additional info:
Comment by @arthurvd:
For me it's fine to change this with a SerializerConfig, just like the (new) ext file does it, for example:

    serializer_config: INISerializerConfig = INISerializerConfig(
        section_indent=0, property_indent=0
    )

Points of attention:

  • Should be done in a nice way such that all MDU fields that are an INIBasedModel get this setting, without too much code duplication (e.g. Geometry, Output, Numerics, etc., etc.
  • there is one SerializerConfig in FMModel itself already, keep it.
@arthurvd arthurvd added this to To do in HYDROLIB-core via automation Mar 31, 2023
@arthurvd arthurvd added the type: enhancement Improvements to existing functionality label Mar 31, 2023
@arthurvd arthurvd added this to the Release 0.5 milestone Mar 31, 2023
@MRVermeulenDeltares MRVermeulenDeltares moved this from To do to In progress in HYDROLIB-core Apr 5, 2023
@MRVermeulenDeltares MRVermeulenDeltares self-assigned this Apr 5, 2023
@MRVermeulenDeltares
Copy link
Contributor

MRVermeulenDeltares commented Apr 5, 2023

@veenstrajelmer do you mean that it will look as followed:


[General]
fileVersion           = 1.09           # File format version (do not edit this)
fileType              = modelDef       # File type. Do not edit this.
program               = D-Flow FM      # Program
version               = 1.2.143.140737 # Version number of computational kernel
autoStart             = 0              # Autostart simulation after loading MDU (0: no, 1: autostart, 2: autostartstop)
pathsRelativeToParent = 0              # Default: 0. Whether or not (1/0) to resolve file names (e.g. inside the *.ext file) relative to their direct parent, instead of to the toplevel MDU working dir.

[Geometry]
netFile                    =
bathymetryFile             =        # Removed since March 2022. See [geometry] keyword BedLevelFile.
dryPointsFile              =
structureFile              =```

@veenstrajelmer
Copy link
Collaborator Author

Indeed

@MRVermeulenDeltares
Copy link
Contributor

MRVermeulenDeltares commented Apr 5, 2023

I tried the following:
493.zip

from that it appears that property_indent= 0 has effect, but section_indent= 0 has no effect.

Defaults of the two are as followed:
section_indent: int = 0
property_indent: int = 4

This makes it clear why section_indent= 0 has no effect

@veenstrajelmer
Copy link
Collaborator Author

veenstrajelmer commented Apr 5, 2023

It appears that the default for property_indent is set to 4. I also noticed indenting of another ini file during your demo. I would suggest to set the default for property_indent to 0 for all ini files (via INISerializerConfig). @arthurvd do you agree?

@MRVermeulenDeltares MRVermeulenDeltares linked a pull request Apr 5, 2023 that will close this issue
@MRVermeulenDeltares MRVermeulenDeltares moved this from In progress to Ready to review in HYDROLIB-core Apr 5, 2023
@arthurvd arthurvd moved this from Ready to review to Review in progress in HYDROLIB-core Apr 7, 2023
@arthurvd arthurvd moved this from Review in progress to Test in HYDROLIB-core Apr 7, 2023
@veenstrajelmer veenstrajelmer removed their assignment Apr 11, 2023
@veenstrajelmer
Copy link
Collaborator Author

Test shows the expected results

@veenstrajelmer veenstrajelmer moved this from Test to Ready to merge in HYDROLIB-core Apr 11, 2023
priscavdsluis pushed a commit that referenced this issue Apr 11, 2023
HYDROLIB-core automation moved this from Ready to merge to Done Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Improvements to existing functionality
Projects
HYDROLIB-core
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants