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

[BUG] Error in lgithgbm quickstart due to change in API for early stopping #1965

Closed
miguelgfierro opened this issue Aug 14, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@miguelgfierro
Copy link
Collaborator

Description

See https://github.com/microsoft/recommenders/actions/runs/5853247386/job/15866899086

tests/smoke/examples/test_notebooks_python.py F.                         [ 96%]
tests/integration/examples/test_notebooks_python.py .                    [100%]

=================================== FAILURES ===================================
________________________ test_lightgbm_quickstart_smoke ________________________

notebooks = ***'als_deep_dive': '/mnt/azureml/cr/j/25a5baf22b8c4b9db7a6c6abea64c9a5/exe/wd/examples/02_model_collaborative_filtering...rk_movielens': '/mnt/azureml/cr/j/25a5baf22b8c4b9db7a6c6abea64c9a5/exe/wd/examples/06_benchmarks/movielens.ipynb', ...***
output_notebook = 'output.ipynb', kernel_name = 'python3'

    @pytest.mark.smoke
    @pytest.mark.notebooks
    def test_lightgbm_quickstart_smoke(notebooks, output_notebook, kernel_name):
        notebook_path = notebooks["lightgbm_quickstart"]
        pm.execute_notebook(
            notebook_path,
            output_notebook,
            kernel_name=kernel_name,
            parameters=dict(
                MAX_LEAF=64,
                MIN_DATA=20,
                NUM_OF_TREES=100,
                TREE_LEARNING_RATE=0.15,
                EARLY_STOPPING_ROUNDS=20,
>               METRIC="auc",
            ),
        )

tests/smoke/examples/test_notebooks_python.py:124: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/azureml-envs/azureml_42c7166d644ccdc54af662a7cb4b4218/lib/python3.7/site-packages/papermill/execute.py:128: in execute_notebook
    raise_for_execution_errors(nb, output_path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

nb = ***'cells': [***'id': '18084673', 'cell_type': 'markdown', 'source': '<span style="color:red; font-family:Helvetica Neue, ...end_time': '2023-08-14T08:35:23.189125', 'duration': 16.39677, 'exception': True***, 'nbformat': 4, 'nbformat_minor': 5***
output_path = 'output.ipynb'

    def raise_for_execution_errors(nb, output_path):
        """Assigned parameters into the appropriate place in the input notebook
    
        Parameters
        ----------
        nb : NotebookNode
           Executable notebook object
        output_path : str
           Path to write executed notebook
        """
        error = None
        for index, cell in enumerate(nb.cells):
            if cell.get("outputs") is None:
                continue
    
            for output in cell.outputs:
                if output.output_type == "error":
                    if output.ename == "SystemExit" and (output.evalue == "" or output.evalue == "0"):
                        continue
                    error = PapermillExecutionError(
                        cell_index=index,
                        exec_count=cell.execution_count,
                        source=cell.source,
                        ename=output.ename,
                        evalue=output.evalue,
                        traceback=output.traceback,
                    )
                    break
    
        if error:
            # Write notebook back out with the Error Message at the top of the Notebook, and a link to
            # the relevant cell (by adding a note just before the failure with an HTML anchor)
            error_msg = ERROR_MESSAGE_TEMPLATE % str(error.exec_count)
            error_msg_cell = nbformat.v4.new_markdown_cell(error_msg)
            error_msg_cell.metadata['tags'] = [ERROR_MARKER_TAG]
            error_anchor_cell = nbformat.v4.new_markdown_cell(ERROR_ANCHOR_MSG)
            error_anchor_cell.metadata['tags'] = [ERROR_MARKER_TAG]
    
            # put the anchor before the cell with the error, before all the indices change due to the
            # heading-prepending
            nb.cells.insert(error.cell_index, error_anchor_cell)
            nb.cells.insert(0, error_msg_cell)
    
            write_ipynb(nb, output_path)
>           raise error
E           papermill.exceptions.PapermillExecutionError: 
E           ---------------------------------------------------------------------------
E           Exception encountered at "In [8]":
E           ---------------------------------------------------------------------------
E           TypeError                                 Traceback (most recent call last)
E           /tmp/ipykernel_137/2864762[359](https://github.com/microsoft/recommenders/actions/runs/5853247386/job/15866899086#step:3:367).py in <module>
E                 7                       early_stopping_rounds=EARLY_STOPPING_ROUNDS,
E                 8                       valid_sets=lgb_valid,
E           ----> 9                       categorical_feature=cate_cols)
E           
E           TypeError: train() got an unexpected keyword argument 'early_stopping_rounds'

/azureml-envs/azureml_42c7166d644ccdc54af662a7cb4b[421](https://github.com/microsoft/recommenders/actions/runs/5853247386/job/15866899086#step:3:429)8/lib/python3.7/site-packages/papermill/execute.py:232: PapermillExecutionError

In which platform does it happen?

How do we replicate the issue?

Expected behavior (i.e. solution)

Other Comments

@miguelgfierro miguelgfierro added the bug Something isn't working label Aug 14, 2023
@miguelgfierro
Copy link
Collaborator Author

Early stopping param is now added to a callable https://github.com/microsoft/LightGBM/releases/tag/v4.0.0. See microsoft/LightGBM#4908

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant