Fix stale method names in the Python API docstrings - #7439
Conversation
Four entries in docstrings_simulators.json carry a signature_template naming a method that does not exist. The generated Sphinx page renders the name from that template, so the published Python API reference documents four methods under names that cannot be called: documented as actually bound as mpi_init setup_mpi get_fluid_state_variable get_fluidstate_variable get_primary_var_meaning get_primary_variable_meaning get_primary_var_meaning_map get_primary_variable_meaning_map A reader who follows the reference and calls sim.mpi_init(...) gets an AttributeError, and one who searches the page for setup_mpi finds nothing. The names on the right are the ones passed to .def() in python/simulators/Py*Simulator.cpp. Only the signature templates were stale; the docstring bodies already use the correct names, for instance the getPrimaryVarMeaning text which refers the reader to get_primary_variable_meaning_map(). This does not affect help() in Python, which pybind11 generates from the binding itself and which already shows the correct names.
The :param finalize: line closed its inline literal with three backticks instead of two, and had no space before the following word: ``MPI_Finalize()```when the simulator object goes out of scope. reStructuredText does not recognize that as a literal, so the published page shows the backticks themselves. Unlike the signature templates, this text is also compiled into the binding, so help(sim.setup_mpi) shows the stray backticks too.
The generated page lists methods in the order the entries appear in docstrings_simulators.json. With the stale names that order happened to be alphabetical, because get_primary_var_meaning sorts before get_primary_variable. Using the real names it no longer is: get_primary_variable sorts before get_primary_variable_meaning. Move getPrimaryVariable ahead of getPrimaryVarMeaning so the published list is alphabetical again. No text changes, only the position of the entry.
|
jenkins build this please |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The documentation now matches the bound methods and has no unresolved blocking issues.
Review effort: Lite
Findings: None
What changed in this PR
Updates generated Python API documentation to match the actual simulator bindings.
Changes:
- Corrects four stale method signatures.
- Fixes malformed
MPI_Finalize()literal markup. - Restores alphabetical method ordering.
| File | Summary |
|---|---|
python/docstrings_simulators.json |
Updates signatures, documentation formatting, and method ordering. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
blattms
left a comment
There was a problem hiding this comment.
Looks good. Does the deployment happen after the merge?
@blattms Yes it should, see It watches the file that this PR changes, and sends a repository_dispatch signal to the other repo. Which should deploy the docs.
|
|
@blattms Following up on my own answer: the deployment did not happen. The dispatch job ran three seconds after the merge and reported success, but its log has this in it: {
"message": "Bad credentials",
"documentation_url": "https://docs.github.com/rest",
"status": "401"
}https://github.com/OPM/opm-simulators/actions/runs/35892130973/job/107286916833 So the Confirmed on both ends: master now has the corrected This has probably been broken for a while rather than being new — Two things that would help, if you agree:
I will also propose adding a In the meantime I can get the current docs published by triggering the documentation build directly, so the merged fix does not sit unpublished while the token is sorted out. |
|
@blattms Published now. Triggered the documentation build by hand, sending the same event the automatic dispatch would have sent, but with my own credentials instead of the repository secret: |
The dispatch step posts to the GitHub API with a bare curl. curl exits 0 for any HTTP response, including an error, so when the request is rejected the step prints the error body and the job still reports success. That is what happened after #7439 was merged: the job was green, but its log shows "message": "Bad credentials", "status": "401" and no documentation build was triggered. Because the job stayed green, nothing indicated that the published Python API reference had not been updated. With --fail-with-body, curl still prints the response body, so the log keeps the reason, but exits with status 22 on an HTTP error, which fails the step. A successful dispatch returns 204 and is unaffected.
Four methods in the generated Python API reference are documented under names that do not exist, so a reader who follows the published reference gets an
AttributeError. The names inpython/docstrings_simulators.jsonwere not updated when the bindingspython/simulators/Py*Simulator.cppwere renamed.mpi_initsetup_mpiget_fluid_state_variableget_fluidstate_variableget_primary_var_meaningget_primary_variable_meaningget_primary_var_meaning_mapget_primary_variable_meaning_mapThis only affects the generated documentation page.
help()in Python is unaffected, because pybind11 builds that signature line from the binding itself and it already shows the correct names.Note: Found while reviewing OPM/opm-python-documentation#31. That review exposed the issue addressed by this PR.
Fix stale method names in the docstring templates (commit 1)
docstrings_simulators.jsonhas asignature_template, and the Sphinx extension renders the method name from that template rather than from the binding — so a stale template silently publishes a name that cannot be called..def()inpython/simulators/Py*Simulator.cpp.getPrimaryVarMeaningtext, for instance, refers the reader toget_primary_variable_meaning_map().Fix a broken literal in the
setup_mpidocstring (commit 2)The
:param finalize:line closed its inline literal with three backticks instead of two, and had no space before the next word:reStructuredText does not recognize that as a literal, so the page shows the backticks themselves.
Unlike the signature templates, this text is compiled into the binding, so
help(sim.setup_mpi)shows the stray backticks too.Restore alphabetical order of the documented methods (commit 3)
get_primary_var_meaningsorts beforeget_primary_variable; with the real names it no longer is.getPrimaryVariableahead ofgetPrimaryVarMeaning. No text changes — only the position of the entry. Kept as a separate commit so it can be dropped if reviewers would rather not have the churn.Verification
common_methodsagainst the methods actually bound, then confirmed against the imported module withhasattrrather than by reading the source.mpi_init,get_fluid_state_variableandget_primary_var_meaningnow appear zero times, the rendered method list matches the module'sdir()exactly and in the same order, and thesetup_mpientry reads "Whether to call MPI_Finalize() when the simulator object goes out of scope" with no stray backticks.