Conversation
Instead of spaces
This was the previously used name.
In this case the / needs to be at the beginning
According to @fsimonis order in precice/config-format#2
fsimonis
left a comment
There was a problem hiding this comment.
We consistently use spaces in preCICE, using tabs here will break this convention.
I propose two ways regarding the formatting:
- Generate output that leads to no changes when applying precice-config-format to it.
- Generate unformatted output, then load precice-config-format as a library and use it to format the output.
I would personally tend towards the latter option, as it doesn't require any future changes.
|
Thank you for the feedback.
Currently, this is not possible as the However, it would be possible to simply create a "global" If this is not desired, then I see only the option to modify the |
and other indent issues
Default values
I moved the functions in their own directories based on their purpose.
Used default helper values
to use the new graph pacakge
At some point you call, to_xml() and generate the string that needs to be written to file. This is the place where you can format the output. |
Added missing attribute and made api_access optional.
fix the bug
fix wrong names
That are expected / optional in our nodes. Still doesnt cover all possible arguments (tags), but at least the most important ones
the test tests that the created config is equivalent to the orginal one and that formatting works as expected.
they now check all available tags
create method for generating only the string.
Optional dependency when creating file.
Now the graph package will be found
and now the optional generate dependency will be installed for testing
Fix imports with new structure
|
To summarize what this does now (because it is a bit more than anticipated):
|
fsimonis
left a comment
There was a problem hiding this comment.
A general improvement would be to switch to single ticks for strings including escaped quotes:
"attrib=\"val\"" → 'attrib="val"'
| try: | ||
| from preciceconfigformat.cli import parseXML, PrettyPrinter | ||
| except ImportError: | ||
| raise ImportError("The precice-config-format library is not installed. " |
There was a problem hiding this comment.
You can add this as a dependency to the package. This way you can assume that the formatter is importable.
| import networkx as nx | ||
| try: | ||
| import matplotlib.pyplot as plt | ||
| except ImportError: |
There was a problem hiding this comment.
Similar story here. You can just add this as a dependency.
| THIN_PLATE_SPLINE = "thin-plate-splines" | ||
| VOLUME_SPLINE = "volume-splines" |
There was a problem hiding this comment.
The enums are now inconsistent though 😉
| return _format_config_string(config_str) | ||
|
|
||
|
|
||
| def _create_unformatted_config_str(config_dict: dict[str, list[n.ParticipantNode | |
There was a problem hiding this comment.
The generated string is still formatted.
I suggest removing all kinds of indentation.
Theoretically, you could even remove the newlines, but this can make debugging a challenge.
The key is simple code.
| f"{h.INDENT}{h.INDENT}{h.INDENT}filter=\"%Severity% > debug\"\n" | ||
| f"{h.INDENT}{h.INDENT}{h.INDENT}format=\"---[precice] %ColorizedSeverity% %Message%\"\n" | ||
| f"{h.INDENT}{h.INDENT}{h.INDENT}enabled=\"true\" />\n" |
There was a problem hiding this comment.
| f"{h.INDENT}{h.INDENT}{h.INDENT}filter=\"%Severity% > debug\"\n" | |
| f"{h.INDENT}{h.INDENT}{h.INDENT}format=\"---[precice] %ColorizedSeverity% %Message%\"\n" | |
| f"{h.INDENT}{h.INDENT}{h.INDENT}enabled=\"true\" />\n" | |
| f"{h.INDENT}{h.INDENT}{h.INDENT}format=\"---[precice] %ColorizedSeverity% %Message%\" />\n" |
They now have a clearer indent (tabs vs spaces) and the elements follow the order described in precice/config-format#2