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 30, 2024
1 parent b1a39fc commit d2f45c5
Show file tree
Hide file tree
Showing 4 changed files with 2,873 additions and 1 deletion.
13 changes: 12 additions & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@ 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):
- Install opm-common
- Copy the file "<opm-common-folder>/python/opm_embedded/__init__.pyi" into the folder at "python.analysis.stubPath" of VS Code and rename it to "opm_embedded.pyi"
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
Original file line number Diff line number Diff line change
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
1 change: 1 addition & 0 deletions python/opm_embedded/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This is the opm_embedded module for embedding python code in PYACTION.
"""

# If you change anything here, please recreate and update the python stub file for opm_embedded as described in python/README.md
from opm.opmcommon_python.embedded import current_ecl_state, current_summary_state, current_schedule, current_report_step
from opm.opmcommon_python import OpmLog
from opm.opmcommon_python import DeckKeyword # Needed for PYINPUT

0 comments on commit d2f45c5

Please sign in to comment.