kedro-org / kedro

Kedro is a toolbox for production-ready data science. It uses software engineering best practices to help you create data engineering and data science pipelines that are reproducible, maintainable, and modular.
https://kedro.org
Apache License 2.0
9.82k stars 895 forks source link

`config_loader` & `hook_manager` arguments for default `KedroContext` test #1408

Closed ARashitov closed 2 years ago

ARashitov commented 2 years ago

Description

TypeError: KedroContext.init() missing 2 required positional arguments: 'config_loader' and 'hook_manager'

Context

I wanted to execute pipelines test

Steps to Reproduce

  1. Create project over kedro new command
  2. Execute kedro test

Expected Result

1 successful test passing of default KedroContext

Actual Result

/home/atmosphere/miniconda3/envs/py3_10_1/bin/python -m pytest
==================================================== test session starts ====================================================
platform linux -- Python 3.10.4, pytest-7.1.1, pluggy-1.0.0
rootdir: /home/atmosphere/Projects/projects_templates, configfile: pyproject.toml
plugins: anyio-3.5.0, cov-3.0.0, asyncio-0.18.3, forked-1.4.0, xdist-2.5.0
asyncio: mode=legacy
collected 1 item                                                                                                            

src/tests/test_run.py E                                                                                               [100%]/home/atmosphere/miniconda3/envs/py3_10_1/lib/python3.10/site-packages/coverage/control.py:793: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")

========================================================== ERRORS ===========================================================
__________________________________ ERROR at setup of TestProjectContext.test_project_path ___________________________________

    @pytest.fixture
    def project_context():
>       return KedroContext(
            package_name="pipelines", project_path=Path.cwd()
        )
E       TypeError: KedroContext.__init__() missing 2 required positional arguments: 'config_loader' and 'hook_manager'

src/tests/test_run.py:19: TypeError
===================================================== warnings summary ======================================================
../../miniconda3/envs/py3_10_1/lib/python3.10/site-packages/pytest_asyncio/plugin.py:191
  /home/atmosphere/miniconda3/envs/py3_10_1/lib/python3.10/site-packages/pytest_asyncio/plugin.py:191: DeprecationWarning: The 'asyncio_mode' default value will change to 'strict' in future, please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' in pytest configuration file.
    config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform linux, python 3.10.4-final-0 -----------
Name                                          Stmts   Miss  Cover   Missing
---------------------------------------------------------------------------
src/pipelines/__init__.py                         1      1     0%   4
src/pipelines/__main__.py                        30     30     0%   4-47
src/pipelines/pipeline_registry.py                5      5     0%   2-15
src/pipelines/pipelines/__init__.py               0      0   100%
src/pipelines/pipelines/example/__init__.py       3      3     0%   6-10
src/pipelines/pipelines/example/nodes.py          4      4     0%   5-15
src/pipelines/pipelines/example/pipeline.py       4      4     0%   6-12
src/pipelines/settings.py                         0      0   100%
---------------------------------------------------------------------------
TOTAL                                            47     47     0%

================================================== short test summary info ==================================================
ERROR src/tests/test_run.py::TestProjectContext::test_project_path - TypeError: KedroContext.__init__() missing 2 required...
================================================ 1 warning, 1 error in 0.32s ================================================

Your Environment

Include as many relevant details about the environment in which you experienced the bug:

avan-sh commented 2 years ago

Hi @AtmosOne,

Looks like a change required for these tests wasn't made in the empty starter. This change made in kedro-starters shows the changes you'll need to make within your project for now.

ARashitov commented 2 years ago

@avan-sh Thank you!

antonymilne commented 2 years ago

Thanks for the bug report @AtmosOne and for the solution @avan-sh. We have an e2e test for kedro test which passes, so it looks like somehow the test project starter has got out of sync with the project template.

In addition to fixing this in the project template I think we should also: