Skip to content

Let the model keep supplying the CLI defaults - #1637

Merged
sjoelund merged 1 commit into
OpenModelica:masterfrom
sjoelund:python-cli-model-defaults
Aug 26, 2026
Merged

Let the model keep supplying the CLI defaults#1637
sjoelund merged 1 commit into
OpenModelica:masterfrom
sjoelund:python-cli-model-defaults

Conversation

@sjoelund

Copy link
Copy Markdown
Member

The CLI gained the C++ flag names in #1631, but also gained an argparse default for each of them. Those defaults are applied unconditionally, so they override the values the model itself provides:

flag C++ CLI after #1631
--startTime DefaultExperiment always 0.0
--stopTime DefaultExperiment always 1.0
--tolerance DefaultExperiment always 1e-4
--stepSize DefaultExperiment always 1e-3
--resultFile <modelName>_res.mat default_res.mat
--mode the FMU's preference always me

oms_extractFMIKind only overrode a DefaultExperiment value when the corresponding flag was explicitlySet, and SimulateSingleFMU only called oms_setResultFile when --resultFile was not <default>. Restore that: every option whose fallback lives in the model or in Flags.h now defaults to None, and the documented default moves into the help text so --help still shows it.

Two more flags could not do what they said:

  • --clearAllOptions is re_void, so the =true the forwarding loop appended made the native parser reject it.
  • --suppressPath was overridden by FMU.instantiate(), which set it unconditionally. That also warned "Flag --suppressPath is set multiple times" whenever the flag was passed. Both call sites now go through Capi.setSuppressPath(), where the first caller wins.

Forwarded arguments are quoted as a whole rather than bare, since the native tokenizer is std::quoted and a value with spaces otherwise splits across tokens.

Finally, install the launcher 0755. It inherited the 0700 of the OMSimulatorPython3 helper it replaced, which leaves bin/OMSimulator unusable by anyone but the installing user.

Assisted-by: Claude Opus 5 (1M context)

Related Issues

Purpose

Approach

The CLI gained the C++ flag names in OpenModelica#1631, but also gained an argparse
default for each of them. Those defaults are applied unconditionally, so
they override the values the model itself provides:

| flag           | C++ CLI                      | after OpenModelica#1631         |
| -------------- | ---------------------------- | ------------------- |
| `--startTime`  | DefaultExperiment            | always 0.0          |
| `--stopTime`   | DefaultExperiment            | always 1.0          |
| `--tolerance`  | DefaultExperiment            | always 1e-4         |
| `--stepSize`   | DefaultExperiment            | always 1e-3         |
| `--resultFile` | `<modelName>_res.mat`        | `default_res.mat`   |
| `--mode`       | the FMU's preference         | always `me`         |

`oms_extractFMIKind` only overrode a DefaultExperiment value when the
corresponding flag was `explicitlySet`, and `SimulateSingleFMU` only
called `oms_setResultFile` when `--resultFile` was not `<default>`.
Restore that: every option whose fallback lives in the model or in
Flags.h now defaults to None, and the documented default moves into the
help text so `--help` still shows it.

Two more flags could not do what they said:

  * `--clearAllOptions` is `re_void`, so the `=true` the forwarding loop
    appended made the native parser reject it.
  * `--suppressPath` was overridden by `FMU.instantiate()`, which set it
    unconditionally. That also warned "Flag --suppressPath is set
    multiple times" whenever the flag was passed. Both call sites now go
    through `Capi.setSuppressPath()`, where the first caller wins.

Forwarded arguments are quoted as a whole rather than bare, since the
native tokenizer is `std::quoted` and a value with spaces otherwise
splits across tokens.

Finally, install the launcher 0755. It inherited the 0700 of the
`OMSimulatorPython3` helper it replaced, which leaves `bin/OMSimulator`
unusable by anyone but the installing user.

Assisted-by: Claude Opus 5 (1M context)
@sjoelund
sjoelund enabled auto-merge (squash) August 26, 2026 11:05
@sjoelund
sjoelund merged commit bb5a80f into OpenModelica:master Aug 26, 2026
4 checks passed
@sjoelund
sjoelund deleted the python-cli-model-defaults branch August 26, 2026 13:15
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.24%. Comparing base (62c758f) to head (e06e629).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1637   +/-   ##
=======================================
  Coverage   29.24%   29.24%           
=======================================
  Files          68       68           
  Lines       12960    12960           
  Branches     8389     8389           
=======================================
  Hits         3790     3790           
  Misses       7979     7979           
  Partials     1191     1191           
Flag Coverage Δ
linux 29.24% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant