Skip to content

Commit

Permalink
Add file and entry in README.md for autocompletion in VS Code
Browse files Browse the repository at this point in the history
  • Loading branch information
lisajulia committed Apr 29, 2024
1 parent b1a39fc commit a41887b
Show file tree
Hide file tree
Showing 4 changed files with 2,872 additions and 1 deletion.
11 changes: 10 additions & 1 deletion python/README.md
Expand Up @@ -2,4 +2,13 @@ This folder contains the Python bindings and code required for embedding python

For the Python bindings, see the [Python bindings of opm-simulators](https://github.com/OPM/opm-simulators/blob/master/python/README.md).

For embedding python, see the [documentation](https://opm-project.org/?page_id=1454).
For embedding python, see the [documentation](https://opm-project.org/?page_id=1454).

To enable tooltips for opm_embedded on VSCode (embedded python code): Copy the file "<opm-common-folder>/python/opm_embedded.pyi" in the folder at "python.analysis.stubPath" of VS Code
You can recreate this stub file by executing "stubgen -m opmcommon_python" in "<opm-common-build-folder>/python/opm", renaming the resuling stub file from "opmcommon_python.pyi" to "opm_embedded.pyi" and adding the lines
```python
current_ecl_state: EclipseState
current_report_step: int
current_schedule: Schedule
current_summary_state: SummaryState
```
1 change: 1 addition & 0 deletions python/cxx/export.cpp
Expand Up @@ -36,6 +36,7 @@ PYBIND11_MODULE(opmcommon_python, module) {
pybind11::module submodule = module.def_submodule("embedded");

// These attributes are placeholders, they get set to the actual EclipseState, Schedule and SummaryState in PyRunModule.cpp
// If you change anything here, please recreate and update the python stub file for opm_embedded as described in python/README.md
submodule.attr("current_ecl_state") = std::make_shared<EclipseState>();
submodule.attr("current_summary_state") = std::make_shared<SummaryState>();
submodule.attr("current_schedule") = std::make_shared<Schedule>();
Expand Down

0 comments on commit a41887b

Please sign in to comment.