Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Providing error message to python in exception #273

Merged
merged 5 commits into from
Sep 20, 2019
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
2 changes: 1 addition & 1 deletion src/NativeBridge/ManagedInterop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
9 changes: 0 additions & 9 deletions src/NativeBridge/ManagedInterop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();

Expand All @@ -107,7 +99,6 @@ class CLASS_ALIGN EnvironmentBlock
int _irowBase;
int _crowWant;
std::vector<void*> _vset;
PyErrorCode _errCode;
std::string _errMessage;

std::vector<std::string> _names;
Expand Down
3 changes: 1 addition & 2 deletions src/NativeBridge/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ bp::dict pxCall(bp::dict& params)
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.");
throw std::runtime_error(env.GetErrorMessage());
}
catch (const std::exception& e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/python/nimbusml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/python/nimbusml/tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 4 additions & 1 deletion src/python/nimbusml/tests/test_syntax_onehotvectorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion src/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1
1.4.2