-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add python bindings for configurations #125
Open
danjujan
wants to merge
15
commits into
vara-dev
Choose a base branch
from
jan-dev
base: vara-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
734feaa
Create Cofiguration bindings for python
danjujan ccd4a5b
Cleanup
danjujan 09238d6
Do not build z3 if it is installed
danjujan 9725979
Fix pre-commit
danjujan 3f79bae
Merge branch 'vara-dev' into jan-dev
danjujan 0f33534
Add GetAllConfigurations2 unittest to detect bug
danjujan eb11193
Do not exclude the first config.
boehmseb 67ac14e
Avoid unnecessary solver calls.
boehmseb b50117d
Use for-each loop to iterate maps.
boehmseb 28bddd7
Temporary fix for side effects of getNextConfiguration()
boehmseb 90071d4
Merge branch 'fix-configuration-generation' into jan-dev
danjujan e638b9d
Merge branch 'fix-configuration-generation' into jan-dev
danjujan 1e5aa2b
Apply suggested changes.
boehmseb 67463ab
Quick-fix to make configuration enumeration work.
boehmseb 20d511b
Merge remote-tracking branch 'origin/fix-configuration-generation' in…
danjujan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "pybind_common.h" | ||
#include "vara/Configuration/Configuration.h" | ||
#include "vara/Solver/ConfigurationFactory.h" | ||
|
||
#include "pybind11/detail/common.h" | ||
#include "pybind11/pybind11.h" | ||
|
||
#include <filesystem> | ||
#include <iostream> | ||
|
||
namespace vf = vara::feature; | ||
namespace vs = vara::solver; | ||
namespace py = pybind11; | ||
|
||
void init_configuration_module(py::module &M) { | ||
py::class_<vf::ConfigurationOption>(M, "ConfigurationOption") | ||
.def_property_readonly( | ||
"name", [](vf::ConfigurationOption &CO) { return CO.name().str(); }, | ||
R"pbdoc(Returns the name of the ConfigurationOption.)pbdoc") | ||
.def_property_readonly( | ||
"value", &vf::ConfigurationOption::asString, | ||
R"pbdoc(Returns the value of the ConfigurationOption as str.)pbdoc"); | ||
py::class_<vf::Configuration>(M, "Configuration") | ||
.def("__str__", [](vf::Configuration &C) { return C.dumpToString(); }) | ||
.def("getOptions", [](vf::Configuration &C) { | ||
std::vector<vf::ConfigurationOption> V; | ||
for (auto &O : C) { | ||
V.push_back(*O.getValue()); | ||
} | ||
|
||
return V; | ||
}); | ||
M.def( | ||
"getAllConfigs", | ||
[](vf::FeatureModel &FM) { | ||
return vs::ConfigurationFactory::getAllConfigs(FM).extractValue(); | ||
}, | ||
R"pbdoc(Get all configurations of FeatureModel. | ||
|
||
Args: | ||
fm (FeatureModel): the FeatureModel | ||
|
||
Returns: list of all configurations. | ||
)pbdoc"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is a good way to determine if we should build the solver.
Maybe we should keep building the solver as the default and give the user a option to disable that? Or, if it works for you, only you use the local one.