From 7f723e79dc86e316b6c70ceb83434566c9005393 Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Fri, 20 Sep 2019 12:02:22 -0700 Subject: [PATCH 1/4] spit out error message to python upgrade patch version --- src/NativeBridge/ManagedInterop.cpp | 2 +- src/NativeBridge/ManagedInterop.h | 9 --------- src/NativeBridge/dllmain.cpp | 6 +++--- src/python/nimbusml/__init__.py | 2 +- src/python/setup.py | 2 +- version.txt | 2 +- 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/NativeBridge/ManagedInterop.cpp b/src/NativeBridge/ManagedInterop.cpp index e31ea6e3..100e9053 100644 --- a/src/NativeBridge/ManagedInterop.cpp +++ b/src/NativeBridge/ManagedInterop.cpp @@ -83,7 +83,6 @@ EnvironmentBlock::EnvironmentBlock(int verbosity, int maxSlots, int seed, const // Assert that this class doesn't have a vtable. assert(offsetof(EnvironmentBlock, verbosity) == 0); - this->_errCode = PyErrorCode_NoError; this->verbosity = verbosity; this->maxSlots = maxSlots; this->seed = seed; @@ -207,6 +206,7 @@ STATIC MANAGED_CALLBACK(void) EnvironmentBlock::MessageSink(EnvironmentBlock * e break; case Error: // We will throw the error when ConnectToMlNet returns sMessage = "Error: " + sMessage; + env->_errMessage = sMessage; break; } diff --git a/src/NativeBridge/ManagedInterop.h b/src/NativeBridge/ManagedInterop.h index e7b54038..f0abf007 100644 --- a/src/NativeBridge/ManagedInterop.h +++ b/src/NativeBridge/ManagedInterop.h @@ -21,13 +21,6 @@ enum MessageKind Error = 3 }; -// These are only used locally -enum PyErrorCode -{ - PyErrorCode_NoError = 0, - PyErrorCode_Failure = 1 -}; - // REVIEW: the exceptions thrown in the callbacks will not be caught by BxlServer on Linux. // On Linux, CoreCLR will ignore previous stack frames, i.e., those before entering the managed code. typedef MANAGED_CALLBACK_PTR(void, MODELSINK) (EnvironmentBlock * env, @@ -87,7 +80,6 @@ class CLASS_ALIGN EnvironmentBlock public: EnvironmentBlock(int verbosity = 0, int maxSlots = -1, int seed = 42, const char* pythonPath = NULL); ~EnvironmentBlock(); - PyErrorCode GetErrorCode() { return _errCode; } std::string GetErrorMessage() { return _errMessage; } bp::dict GetData(); @@ -107,7 +99,6 @@ class CLASS_ALIGN EnvironmentBlock int _irowBase; int _crowWant; std::vector _vset; - PyErrorCode _errCode; std::string _errMessage; std::vector _names; diff --git a/src/NativeBridge/dllmain.cpp b/src/NativeBridge/dllmain.cpp index cbad43ba..f2b31ba6 100644 --- a/src/NativeBridge/dllmain.cpp +++ b/src/NativeBridge/dllmain.cpp @@ -114,11 +114,11 @@ bp::dict pxCall(bp::dict& params) else retCode = exec(&env, s_graph.c_str(), 0, NULL); + if (retCode == -1) + throw std::runtime_error(env.GetErrorMessage()); + res = env.GetData(); - if (retCode == -1) - // REVIEW: get the content of IChannel and add it the the error message. - throw std::runtime_error("Returned code is -1. Check the log for error messages."); } catch (const std::exception& e) { diff --git a/src/python/nimbusml/__init__.py b/src/python/nimbusml/__init__.py index 43fc693c..4e18a65b 100644 --- a/src/python/nimbusml/__init__.py +++ b/src/python/nimbusml/__init__.py @@ -2,7 +2,7 @@ Microsoft Machine Learning for Python """ -__version__ = '1.4.1' +__version__ = '1.4.2' # CoreCLR version of MicrosoftML is built on Windows. # But file permissions are not preserved when it's copied to Linux. diff --git a/src/python/setup.py b/src/python/setup.py index 90692131..7b983db8 100644 --- a/src/python/setup.py +++ b/src/python/setup.py @@ -45,7 +45,7 @@ # Versions should comply with PEP440. For a discussion on # single-sourcing the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version='1.4.1', + version='1.4.2', description='NimbusML', long_description=long_description, diff --git a/version.txt b/version.txt index 13175fdc..c9929e36 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.4.1 \ No newline at end of file +1.4.2 \ No newline at end of file From c7b9f6d7d77fa5688b1ba359d96c9a0309b428ce Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Fri, 20 Sep 2019 12:36:11 -0700 Subject: [PATCH 2/4] fix the test --- src/python/nimbusml/tests/test_errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/nimbusml/tests/test_errors.py b/src/python/nimbusml/tests/test_errors.py index df14baf2..744ac275 100644 --- a/src/python/nimbusml/tests/test_errors.py +++ b/src/python/nimbusml/tests/test_errors.py @@ -41,7 +41,7 @@ def test_error_wrong_column_name(self): raise Exception( 'boost.python did not replace the exception.\n{0}'.format( e)) - assert "Check the log for error messages" in str(e) + assert "Error: *** System.ArgumentOutOfRangeException: 'Could not find input column" in str(e) @unittest.skip("System.NullReferenceException") def test_char_tokenizer(self): From dcd36c735de37289ba0201f31f3983fec6f906bb Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Fri, 20 Sep 2019 12:39:51 -0700 Subject: [PATCH 3/4] another test --- src/python/nimbusml/tests/test_syntax_onehotvectorizer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/python/nimbusml/tests/test_syntax_onehotvectorizer.py b/src/python/nimbusml/tests/test_syntax_onehotvectorizer.py index 556271af..c31879c1 100644 --- a/src/python/nimbusml/tests/test_syntax_onehotvectorizer.py +++ b/src/python/nimbusml/tests/test_syntax_onehotvectorizer.py @@ -79,7 +79,7 @@ def test_syntax5_failing(self): vec.fit_transform(X, verbose=2) assert False except RuntimeError as e: - assert "Returned code is -1. Check the log for error messages.." \ + assert "Error: *** System.ArgumentOutOfRangeException: 'Could not find input column" \ in str(e) vec = OneHotVectorizer() << {'edu1': ['education']} res = vec.fit_transform(X) @@ -147,3 +147,6 @@ def test_syntax9_multiple_inputs(self): 'out1': ['education1', 'education2']} output4 = ng4.fit_transform(X) assert output4.shape == (5, 13) + +if __name__ == '__main__': + unittest.main() From 637da8a61a58268a22443e8a7280645c082ed43f Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Fri, 20 Sep 2019 15:36:33 -0700 Subject: [PATCH 4/4] rollback --- src/NativeBridge/dllmain.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/NativeBridge/dllmain.cpp b/src/NativeBridge/dllmain.cpp index f2b31ba6..1a7a297d 100644 --- a/src/NativeBridge/dllmain.cpp +++ b/src/NativeBridge/dllmain.cpp @@ -114,11 +114,10 @@ bp::dict pxCall(bp::dict& params) else retCode = exec(&env, s_graph.c_str(), 0, NULL); - if (retCode == -1) - throw std::runtime_error(env.GetErrorMessage()); - res = env.GetData(); + if (retCode == -1) + throw std::runtime_error(env.GetErrorMessage()); } catch (const std::exception& e) {