Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposes ModuleBase's RuntimeView Object to Python #358

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ nwx_cxx_api_docs("README.md" "${project_inc_dir}" "${project_src_dir}")
### Options ###
cmaize_option_list(
BUILD_TESTING OFF "Should we build unit tests?"
BUILD_PYBIND11_PYBINDINGS OFF "Build Pybind11 Python bindings?"
BUILD_PYBIND11_PYBINDINGS ON "Build Pybind11 Python bindings?"
BUILD_ROCKSDB OFF "Enable RocksDB backend of the cache?"
)

Expand Down Expand Up @@ -152,10 +152,6 @@ if("${BUILD_TESTING}")

### Python Tests ###
set(python_test_dir "${CMAKE_CURRENT_LIST_DIR}/tests/python")
cmaize_find_or_build_dependency(
tox
PACKAGE_MANAGER pip
)

# In the python tests we will pass Python into PluginPlay, we will then
# need to know that C++ can handle those Python types. To this end we
Expand All @@ -166,11 +162,11 @@ if("${BUILD_TESTING}")
INSTALL OFF
SOURCE_DIR "${python_test_dir}/unit_tests"
INCLUDE_DIRS "${project_inc_dir}"
DEPENDS ${PROJECT_NAME} tox
DEPENDS ${PROJECT_NAME}
)

nwx_tox_test(
py_pluginplay ${python_test_dir}/unit_tests
nwx_pybind11_tests(
py_pluginplay ${python_test_dir}/unit_tests/test_pluginplay.py
SUBMODULES parallelzone
)

Expand Down
1 change: 1 addition & 0 deletions src/python/module/export_module_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void export_module_base(py_module_reference m) {
.def("property_types", &ModuleBase::property_types)
.def("get_desc", &ModuleBase::get_desc)
.def("citations", &ModuleBase::citations)
.def("get_runtime", &ModuleBase::get_runtime)
// //.def("set_cache", &ModuleBase::set_cache)
// .def("get_cache", &ModuleBase::get_cache)
// .def("reset_internal_cache", &ModuleBase::reset_internal_cache)
Expand Down
2 changes: 2 additions & 0 deletions tests/python/unit_tests/module/test_module_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import pluginplay as pp
import parallelzone as pz
import py_test_pluginplay as test_pp
import unittest

Expand All @@ -33,6 +34,7 @@ def run_(self, inputs, submods):
i0, = pt.unwrap_inputs(inputs)
i1 = inputs["An extra input"].value()

assert (self.get_runtime() == pz.runtime.RuntimeView())
r0 = submods["A submodule"].run_as(pt, i0 + i1)

rv = self.results()
Expand Down
Loading