Skip to content
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

macOS python tests fail #1519

Closed
StrikerRUS opened this issue Jul 13, 2018 · 7 comments
Closed

macOS python tests fail #1519

StrikerRUS opened this issue Jul 13, 2018 · 7 comments

Comments

@StrikerRUS
Copy link
Collaborator

StrikerRUS commented Jul 13, 2018

Plotting tests with graphviz fail.

UPD: Python 3.5 still works fine

Environment info

Operating System: macOS
C++/Python/R version: Python 2.7, 3.4, 3.6

Error Message:

============================= test session starts ==============================
platform darwin -- Python 3.6.6, pytest-3.6.2, py-1.5.3, pluggy-0.6.0
rootdir: /Users/travis/build/Microsoft/LightGBM, inifile:
collected 56 items                                                             
../tests/c_api_test/test_.py ssssss..                                    [ 14%]
../tests/python_package_test/test_basic.py ..                            [ 17%]
../tests/python_package_test/test_consistency.py ....                    [ 25%]
../tests/python_package_test/test_engine.py ......................       [ 64%]
../tests/python_package_test/test_plotting.py F..F                       [ 71%]
../tests/python_package_test/test_sklearn.py ................            [100%]

=================================== FAILURES ===================================
______________________ TestBasic.test_create_tree_digraph ______________________

self = <test_plotting.TestBasic testMethod=test_create_tree_digraph>

    @unittest.skipIf(not GRAPHVIZ_INSTALLED, 'graphviz is not installed')
    def test_create_tree_digraph(self):
        gbm = lgb.LGBMClassifier(n_estimators=10, num_leaves=3, silent=True)
        gbm.fit(self.X_train, self.y_train, verbose=False)
    
        self.assertRaises(IndexError, lgb.create_tree_digraph, gbm, tree_index=83)
    
        graph = lgb.create_tree_digraph(gbm, tree_index=3,
                                        show_info=['split_gain', 'internal_value'],
                                        name='Tree4', node_attr={'color': 'red'})
>       graph.render(view=False)

../tests/python_package_test/test_plotting.py:85: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../../miniconda/envs/test-env/lib/python3.6/site-packages/graphviz/files.py:176: in render
    rendered = backend.render(self._engine, self._format, filepath)
../../../../miniconda/envs/test-env/lib/python3.6/site-packages/graphviz/backend.py:124: in render
    subprocess.check_call(args, startupinfo=STARTUPINFO, stderr=stderr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
popenargs = (['dot', '-Tpdf', '-O', 'Tree4.gv'],)
kwargs = {'startupinfo': None, 'stderr': None}, retcode = -6
cmd = ['dot', '-Tpdf', '-O', 'Tree4.gv']
    def check_call(*popenargs, **kwargs):
        """Run command with arguments.  Wait for command to complete.  If
        the exit code was zero then return, otherwise raise
        CalledProcessError.  The CalledProcessError object will have the
        return code in the returncode attribute.
    
        The arguments are the same as for the call function.  Example:
    
        check_call(["ls", "-l"])
        """
        retcode = call(*popenargs, **kwargs)
        if retcode:
            cmd = kwargs.get("args")
            if cmd is None:
                cmd = popenargs[0]
>           raise CalledProcessError(retcode, cmd)
E           subprocess.CalledProcessError: Command '['dot', '-Tpdf', '-O', 'Tree4.gv']' died with <Signals.SIGABRT: 6>.

../../../../miniconda/envs/test-env/lib/python3.6/subprocess.py:291: CalledProcessError
----------------------------- Captured stderr call -----------------------------
dyld: lazy symbol binding failed: Symbol not found: _cairo_quartz_font_face_create_for_cgfont
  Referenced from: /Users/travis/miniconda/envs/test-env/lib/libpangocairo-1.0.0.dylib
  Expected in: /Users/travis/miniconda/envs/test-env/lib/libcairo.2.dylib

dyld: Symbol not found: _cairo_quartz_font_face_create_for_cgfont
  Referenced from: /Users/travis/miniconda/envs/test-env/lib/libpangocairo-1.0.0.dylib
  Expected in: /Users/travis/miniconda/envs/test-env/lib/libcairo.2.dylib

___________________________ TestBasic.test_plot_tree ___________________________

self = <test_plotting.TestBasic testMethod=test_plot_tree>

    @unittest.skipIf(not MATPLOTLIB_INSTALLED or not GRAPHVIZ_INSTALLED, 'matplotlib or graphviz is not installed')
    def test_plot_tree(self):
        gbm = lgb.LGBMClassifier(n_estimators=10, num_leaves=3, silent=True)
        gbm.fit(self.X_train, self.y_train, verbose=False)
    
        self.assertRaises(IndexError, lgb.plot_tree, gbm, tree_index=83)
    
>       ax = lgb.plot_tree(gbm, tree_index=3, figsize=(15, 8), show_info=['split_gain'])

../tests/python_package_test/test_plotting.py:69: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../../miniconda/envs/test-env/lib/python3.6/site-packages/lightgbm/plotting.py:462: in plot_tree
    s.write(graph.pipe(format='png'))
../../../../miniconda/envs/test-env/lib/python3.6/site-packages/graphviz/files.py:125: in pipe
    outs = backend.pipe(self._engine, format, data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

engine = 'dot', format = 'png'
data = b'digraph {\n\tsplit0 [label="split_feature_name: Column_22\\nthreshold: 105.95000000000002\\nsplit_gain: 204.76800537...l="leaf_index: 2\\nleaf_value: -0.1745686284011742"]\n\tsplit1 -> leaf2 [label=">"]\n\tsplit0 -> split1 [label=">"]\n}'
quiet = False

    def pipe(engine, format, data, quiet=False):
        """Return ``data`` piped through Graphviz ``engine`` into ``format``.
    
        Args:
            engine: The layout commmand used for rendering (``'dot'``, ``'neato'``, ...).
            format: The output format used for rendering (``'pdf'``, ``'png'``, ...).
            data: The binary (encoded) DOT source string to render.
            quiet (bool): Suppress ``stderr`` output on non-zero exit status.
        Returns:
            Binary (encoded) stdout of the layout command.
        Raises:
            ValueError: If ``engine`` or ``format`` are not known.
            graphviz.ExecutableNotFound: If the Graphviz executable is not found.
            subprocess.CalledProcessError: If the exit status is non-zero.
        """
        args, _ = command(engine, format)
    
        try:
            proc = subprocess.Popen(args, stdin=subprocess.PIPE,
                stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                startupinfo=STARTUPINFO)
        except OSError as e:
            if e.errno == errno.ENOENT:
                raise ExecutableNotFound(args)
            else:  # pragma: no cover
                raise
    
        outs, errs = proc.communicate(data)
        if proc.returncode:
            if not quiet:
                stderr_write_binary(errs)
                sys.stderr.flush()
>           raise subprocess.CalledProcessError(proc.returncode, args, output=outs)
E           subprocess.CalledProcessError: Command '['dot', '-Tpng']' died with <Signals.SIGABRT: 6>.

../../../../miniconda/envs/test-env/lib/python3.6/site-packages/graphviz/backend.py:166: CalledProcessError
----------------------------- Captured stderr call -----------------------------
dyld: lazy symbol binding failed: Symbol not found: _cairo_quartz_font_face_create_for_cgfont
  Referenced from: /Users/travis/miniconda/envs/test-env/lib/libpangocairo-1.0.0.dylib
  Expected in: /Users/travis/miniconda/envs/test-env/lib/libcairo.2.dylib

dyld: Symbol not found: _cairo_quartz_font_face_create_for_cgfont
  Referenced from: /Users/travis/miniconda/envs/test-env/lib/libpangocairo-1.0.0.dylib
  Expected in: /Users/travis/miniconda/envs/test-env/lib/libcairo.2.dylib
@StrikerRUS
Copy link
Collaborator Author

All Python environments have the same versions of graphviz.

graphviz: 2.40.1
python-graphviz: 0.8.3

@StrikerRUS
Copy link
Collaborator Author

Issue can be solved by pinning the version of fontconfig

conda install "fontconfig=2.12.6"

(new broken version is 2.13.0).

Also possible candidates to be checked:

The following packages will be DOWNGRADED:
    cairo:      1.14.12-hc4e6be7_3   --> 1.14.12-he60d9cb_2  
    fontconfig: 2.13.0-h5d5b041_1    --> 2.12.6-h9850fc5_0   
    freetype:   2.9.1-hb4e5f40_0     --> 2.8-h12048fb_1      
    graphviz:   2.40.1-hefbbd9a_2    --> 2.40.1-h0a44026_0   
    harfbuzz:   1.7.6-hb8d4a28_3     --> 1.7.6-h171471c_1    
    matplotlib: 2.2.2-py27hbf02d85_2 --> 2.2.2-py27ha7267d0_0
    pango:      1.42.1-he2d0c7e_2    --> 1.41.0-h3bae10e_0   

@StrikerRUS
Copy link
Collaborator Author

StrikerRUS commented Jul 13, 2018

Downgrading pango also works:

conda install "pango=1.42.0"
The following packages will be DOWNGRADED:
    cairo:      1.14.12-hc4e6be7_3   --> 1.14.12-hab642c4_1  
    fontconfig: 2.13.0-h5d5b041_1    --> 2.12.6-h9850fc5_0   
    freetype:   2.9.1-hb4e5f40_0     --> 2.8-h12048fb_1      
    glib:       2.56.1-h35bc53a_0    --> 2.53.6-h33f6a65_2   
    graphviz:   2.40.1-hefbbd9a_2    --> 2.40.1-h0a44026_0   
    harfbuzz:   1.7.6-hb8d4a28_3     --> 1.7.6-h08e020e_0    
    matplotlib: 2.2.2-py36hbf02d85_2 --> 2.2.2-py36ha7267d0_0
    pango:      1.42.1-he2d0c7e_2    --> 1.42.0-h0f8274a_0  

@StrikerRUS
Copy link
Collaborator Author

Downgrading freetype also works:

conda install "freetype=2.8"
The following packages will be DOWNGRADED:
    cairo:      1.14.12-hc4e6be7_3   --> 1.14.12-he60d9cb_2  
    fontconfig: 2.13.0-h5d5b041_1    --> 2.12.6-h9850fc5_0   
    freetype:   2.9.1-hb4e5f40_0     --> 2.8-h12048fb_1      
    graphviz:   2.40.1-hefbbd9a_2    --> 2.40.1-h0a44026_0   
    harfbuzz:   1.7.6-hb8d4a28_3     --> 1.7.6-h171471c_1    
    matplotlib: 2.2.2-py27hbf02d85_2 --> 2.2.2-py27ha7267d0_0
    pango:      1.42.1-he2d0c7e_2    --> 1.41.0-h3bae10e_0

@StrikerRUS
Copy link
Collaborator Author

StrikerRUS commented Jul 13, 2018

To sum-up:

downgrading of the following packages works:

  • fontconfig
  • pango
  • freetype

Unfortunately, all of them downgrade each other, so it's difficult to identify the root cause of the problem.

According to the error log

dyld: Symbol not found: _cairo_quartz_font_face_create_for_cgfont
  Referenced from: /Users/travis/miniconda/envs/test-env/lib/libpangocairo-1.0.0.dylib
  Expected in: /Users/travis/miniconda/envs/test-env/lib/libcairo.2.dylib

and the information from https://anaconda.org/anaconda:

pango: Last upload: 11 hours and 30 minutes ago
freetype: Last upload: 9 days and 14 hours ago
fontconfig: Last upload: 9 days and 14 hours ago

I suppose we should pin the version of pango.

@StrikerRUS
Copy link
Collaborator Author

StrikerRUS commented Jul 13, 2018

What do you thing guys?
@guolinke @chivee @henry0312 @wxchan

UPD:
And the second question:
In which package repo bug report should be thrown?

@StrikerRUS
Copy link
Collaborator Author

The problem has been solved in ContinuumIO/anaconda-issues#9763
They just forgot to upload new build at conda

@lock lock bot locked as resolved and limited conversation to collaborators Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant