Skip to content

Commit

Permalink
Try opm.embedded instead of opm_embedded
Browse files Browse the repository at this point in the history
  • Loading branch information
lisajulia committed Apr 25, 2024
1 parent 7d1149f commit 9f25cb7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion opm/input/eclipse/Python/PyRunModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ PyRunModule::PyRunModule(std::shared_ptr<const Python> python, const std::string

// opm_embedded needs to be loaded before user defined module.
try {
this->opm_embedded = py::module::import("opm_embedded");
this->opm_embedded = py::module::import("opm.embedded");
} catch (const std::exception& e) {
OpmLog::error(fmt::format("Exception thrown when loading Python module opm_embedded: {}"), e.what());
throw e;
Expand Down
4 changes: 2 additions & 2 deletions opm/input/eclipse/Python/PythonInterp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool PythonInterp::exec(const std::string& python_code, const Parser& parser, De
if (!this->guard)
throw std::logic_error("Python interpreter not enabled");

auto context = py::module::import("opm_embedded");
auto context = py::module::import("opm.embedded");
context.attr("deck") = &deck;
context.attr("parser") = &parser;
return this->exec(python_code, context);
Expand All @@ -59,7 +59,7 @@ bool PythonInterp::exec(const std::string& python_code) {
if (!this->guard)
throw std::logic_error("Python interpreter not enabled");

auto context = py::module::import("opm_embedded");
auto context = py::module::import("opm.embedded");
return this->exec(python_code, context);
}

Expand Down
1 change: 1 addition & 0 deletions python/opm/_embedded.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .opmcommon_python.embedded import current_ecl_state, current_summary_state, current_schedule, current_report_step
5 changes: 5 additions & 0 deletions python/opm/embedded/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
This is the opm_embedded module for embedding python code in PYACTION.
"""

from opm._embedded import current_ecl_state, current_summary_state, current_schedule, current_report_step
3 changes: 2 additions & 1 deletion python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ setup(
'opm.io.schedule',
'opm.io.ecl',
'opm.tools',
'opm.util'
'opm.util',
'opm.embedded'
],
package_data={'opm' : ['$<TARGET_FILE_NAME:opmcommon_python>']},
include_package_data=True,
Expand Down

0 comments on commit 9f25cb7

Please sign in to comment.