Disable Warning messages in python clfs

Disable removing Python env
This commit is contained in:
Ricardo Montañana Gómez 2023-11-16 22:38:46 +01:00
parent 408db2aad5
commit e2249eace7
Signed by: rmontanana
GPG Key ID: 46064262FD9A7ADE
3 changed files with 23 additions and 18 deletions

26
.vscode/launch.json vendored
View File

@ -5,7 +5,7 @@
"type": "lldb",
"request": "launch",
"name": "sample",
"program": "${workspaceFolder}/build/sample/BayesNetSample",
"program": "${workspaceFolder}/build_debug/sample/BayesNetSample",
"args": [
"-d",
"iris",
@ -14,7 +14,7 @@
"-s",
"271",
"-p",
"/Users/rmontanana/Code/discretizbench/datasets/",
"/home/rmontanana/Code/discretizbench/datasets/",
],
//"cwd": "${workspaceFolder}/build/sample/",
},
@ -22,24 +22,24 @@
"type": "lldb",
"request": "launch",
"name": "experiment",
"program": "${workspaceFolder}/build/src/Platform/b_main",
"program": "${workspaceFolder}/build_debug/src/Platform/b_main",
"args": [
"-m",
"STree",
"--stratified",
"-d",
"zoo",
"--discretize"
"iris",
//"--discretize"
// "--hyperparameters",
// "{\"repeatSparent\": true, \"maxModels\": 12}"
],
"cwd": "/Users/rmontanana/Code/odtebench",
"cwd": "/home/rmontanana/Code/discretizbench",
},
{
"type": "lldb",
"request": "launch",
"name": "best",
"program": "${workspaceFolder}/build/src/Platform/b_best",
"program": "${workspaceFolder}/build_debug/src/Platform/b_best",
"args": [
"-m",
"BoostAODE",
@ -47,24 +47,24 @@
"accuracy",
"--build",
],
"cwd": "/Users/rmontanana/Code/discretizbench",
"cwd": "/home/rmontanana/Code/discretizbench",
},
{
"type": "lldb",
"request": "launch",
"name": "manage",
"program": "${workspaceFolder}/build/src/Platform/b_manage",
"program": "${workspaceFolder}/build_debug/src/Platform/b_manage",
"args": [
"-n",
"20"
],
"cwd": "/Users/rmontanana/Code/discretizbench",
"cwd": "/home/rmontanana/Code/discretizbench",
},
{
"type": "lldb",
"request": "launch",
"name": "list",
"program": "${workspaceFolder}/build/src/Platform/b_list",
"program": "${workspaceFolder}/build_debug/src/Platform/b_list",
"args": [],
//"cwd": "/Users/rmontanana/Code/discretizbench",
"cwd": "/home/rmontanana/Code/covbench",
@ -73,7 +73,7 @@
"type": "lldb",
"request": "launch",
"name": "test",
"program": "${workspaceFolder}/build/tests/unit_tests",
"program": "${workspaceFolder}/build_debug/tests/unit_tests",
"args": [
"-c=\"Metrics Test\"",
// "-s",
@ -84,7 +84,7 @@
"name": "Build & debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bayesnet",
"program": "${workspaceFolder}/build_debug/bayesnet",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",

View File

@ -168,8 +168,8 @@ namespace platform {
fold = new StratifiedKFold(nfolds, y, seed);
else
fold = new KFold(nfolds, y.size(0), seed);
auto clf = Models::instance()->create(model);
for (int nfold = 0; nfold < nfolds; nfold++) {
auto clf = Models::instance()->create(model);
setModelVersion(clf->getVersion());
if (hyperparameters.size() != 0) {
clf->setHyperparameters(hyperparameters);
@ -211,8 +211,8 @@ namespace platform {
result.addTimeTrain(train_time[item].item<double>());
result.addTimeTest(test_time[item].item<double>());
item++;
clf.reset();
}
clf.reset();
if (!quiet)
std::cout << "end. " << flush;
delete fold;

View File

@ -5,6 +5,7 @@
#include <map>
#include <sstream>
#include <boost/python/numpy.hpp>
#include <iostream>
namespace pywrap {
namespace np = boost::python::numpy;
@ -19,6 +20,7 @@ namespace pywrap {
if (wrapper == nullptr) {
wrapper = new PyWrap();
pyInstance = new CPyInstance();
PyRun_SimpleString("import warnings;warnings.filterwarnings('ignore')");
}
return wrapper;
}
@ -59,6 +61,7 @@ namespace pywrap {
void PyWrap::clean(const clfId_t id)
{
// Remove Python interpreter if no more modules imported left
// std::cout << "*Cleaning module " << id << std::endl;
std::lock_guard<std::mutex> lock(mutex);
auto result = moduleClassMap.find(id);
if (result == moduleClassMap.end()) {
@ -72,9 +75,11 @@ namespace pywrap {
PyErr_Print();
errorAbort("Error cleaning module ");
}
if (moduleClassMap.empty()) {
RemoveInstance();
}
// if (moduleClassMap.empty()) {
// RemoveInstance();
// std::cout << "*Python interpreter cleaned" << std::endl;
// }
// std::cout << "*Module " << id << " cleaned" << std::endl;
}
void PyWrap::errorAbort(const std::string& message)
{