IBM/lale

module resolution issue in pretty_print()

Opened this issue · 4 comments

Hi All,

I have implemented a custom imputer based on Scikit-learn SimpleImputer as an example.
My code lives in albert_imputer.py.
Everything in fine until the final result is being printed.
This is what I see in debugger:

> /Users/albert/miniconda3/envs/lale/lib/python3.7/site-packages/lale/pretty_print.py(160)_get_module_name()
-> op = find_op(mod_name_short, op_name)
(Pdb) l
155  	    mod_name_long = class_name[: class_name.rfind(".")]
156  	    mod_name_short = mod_name_long[: mod_name_long.rfind(".")]
157  	    unqualified = class_name[class_name.rfind(".") + 1 :]
158  	    if class_name.startswith("lale.") and unqualified.endswith("Impl"):
159  	        unqualified = unqualified[: -len("Impl")]
160  ->	    op = find_op(mod_name_short, op_name)
161  	    if op is not None:
162  	        mod = mod_name_short
163  	    else:
164  	        op = find_op(mod_name_long, op_name)
165  	        if op is not None:
(Pdb) p mod_name_long, mod_name_short, unqualified,
('albert_imputer', 'albert_impute', 'AlbertImputerImpl')

In "mod_name_short" the last "r" is missed. For this reason, importlib cannot load the module in find_op().
As a temporary workaround, I created a symbolic link "albert_impute.py" to "albert_imputer.py" file and it works.

Hi, thank you for raising this! I think I know what went wrong, will work on a fix.

Please let me know if the fix works for you.

Hi Martin, I do not see any difference yet:
pip3 install "lale[full]" -U

Btw, installation does not work on OSX without quotation: pip3 install "lale[full]", but this is another story ...

Sorry, I should have mentioned that this is only fixed in github, but the fix hasn't been included in a pypi release yet. In the meantime, one way to try out the fix is with pip install -i https://test.pypi.org/simple/ lale. More generally, all successful builds cause an automated release to test.pypi.