Galen Seilis
10/01/2024, 10:42 PMJuan Luis
10/01/2024, 10:47 PMJuan Luis
10/01/2024, 10:47 PMpip install --editable .
(with .
being the path where pyproject.toml
is)Juan Luis
10/01/2024, 10:47 PMpytest
won't find any local modules you have under src/{project_name}
Juan Luis
10/01/2024, 10:47 PMGalen Seilis
10/01/2024, 10:47 PMJuan Luis
10/01/2024, 10:48 PMGalen Seilis
10/01/2024, 10:51 PMkedro_foo
I got this after following the steps (including running pip install --editable .
)
\kedro_foo\foo> pytest
\kedro_foo\venv\lib\site-packages\_pytest\config\__init__.py:331: PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
Plugin: helpconfig, Hook: pytest_cmdline_parse
UsageError: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --cov-report --cov src/foo
inifile: \kedro_foo\foo\pyproject.toml
rootdir: \kedro_foo\foo
For more information see <https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning>
config = pluginmanager.hook.pytest_cmdline_parse(
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --cov-report --cov src/foo
inifile: \kedro_foo\foo\pyproject.toml
rootdir: \kedro_foo\foo
Galen Seilis
10/01/2024, 10:53 PMfoo
. kedro foo
is just a folder I made above it.Juan Luis
10/01/2024, 10:55 PMaddopts
in the pytest conf) and you don't have pytest-cov
installedJuan Luis
10/01/2024, 10:55 PMpip install pytest-cov
or tweak the pytest configGalen Seilis
10/01/2024, 10:56 PMrequirements.txt
. I will try installing pytest-cov
and then running pytest
again.Juan Luis
10/01/2024, 10:57 PMrequirements.txt
of the default kedro new
template, which is consistent with https://github.com/kedro-org/kedro/blob/ba981350ad57dbcaabf5fd758a9a3d4399a91f20/k[…]project/%7B%7B%20cookiecutter.repo_name%20%7D%7D/pyproject.tomlGalen Seilis
10/01/2024, 10:59 PM> pytest
================================================= test session starts =================================================
platform win32 -- Python 3.10.4, pytest-7.4.4, pluggy-1.5.0
rootdir: \kedro_foo\foo
configfile: pyproject.toml
plugins: anyio-3.7.1, cov-5.0.0
collected 1 item
tests\test_run.py E [100%]\kedro_foo\venv\lib\site-packages\coverage\control.py:894: 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 ________________________________
config_loader = OmegaConfigLoader(conf_source=\kedro_foo\foo, env=None, runtime_params={}, config_patterns={'catalog': ['c.../credentials*'], 'globals': ['globals.yml']}, base_env=), default_run_env=), custom_resolvers=None), merge_strategy={})
@pytest.fixture
def project_context(config_loader):
> return KedroContext(
package_name="foo",
project_path=Path.cwd(),
config_loader=config_loader,
hook_manager=_create_hook_manager(),
)
E TypeError: KedroContext.__init__() missing 1 required positional argument: 'env'
tests\test_run.py:23: TypeError
---------- coverage: platform win32, python 3.10.4-final-0 -----------
Name Stmts Miss Cover Missing
-------------------------------------------------------------
src\foo\__init__.py 1 1 0% 4
src\foo\__main__.py 14 14 0% 4-24
src\foo\pipeline_registry.py 7 7 0% 2-16
src\foo\pipelines\__init__.py 0 0 100%
src\foo\settings.py 7 7 0% 15-37
-------------------------------------------------------------
TOTAL 29 29 0%
=============================================== short test summary info ===============================================
ERROR tests/test_run.py::TestProjectContext::test_project_path - TypeError: KedroContext.__init__() missing 1 required positional argument: 'env'
================================================== 1 error in 1.17s ===================================================
Galen Seilis
10/01/2024, 11:01 PMpyproject.toml
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "foo"
readme = "README.md"
dynamic = ["dependencies", "version"]
[project.scripts]
foo = "foo.__main__:main"
[project.entry-points."kedro.hooks"]
[project.optional-dependencies]
docs = [
"docutils<0.21",
"sphinx>=5.3,<7.3",
"sphinx_rtd_theme==2.0.0",
"nbsphinx==0.8.1",
"sphinx-autodoc-typehints==1.20.2",
"sphinx_copybutton==0.5.2",
"ipykernel>=5.3, <7.0",
"Jinja2<3.2.0",
"myst-parser>=1.0,<2.1"
]
dev = [
"pytest-cov~=3.0",
"pytest-mock>=1.7.1, <2.0",
"pytest~=7.2",
"ruff~=0.1.8"
]
[tool.setuptools.dynamic]
dependencies = {file = "requirements.txt"}
version = {attr = "foo.__version__"}
[tool.setuptools.packages.find]
where = ["src"]
namespaces = false
[tool.kedro]
package_name = "foo"
project_name = "foo"
kedro_init_version = "0.19.8"
tools = ['Linting', 'Testing', 'Custom Logging', 'Documentation', 'Data Structure', 'Kedro Viz']
example_pipeline = "False"
source_dir = "src"
[tool.pytest.ini_options]
addopts = """
--cov-report term-missing \
--cov src/foo -ra"""
[tool.coverage.report]
fail_under = 0
show_missing = true
exclude_lines = ["pragma: no cover", "raise NotImplementedError"]
[tool.ruff.format]
docstring-code-format = true
[tool.ruff]
line-length = 88
show-fixes = true
select = [
"F", # Pyflakes
"W", # pycodestyle
"E", # pycodestyle
"I", # isort
"UP", # pyupgrade
"PL", # Pylint
"T201", # Print Statement
]
ignore = ["E501"] # Ruff format takes care of line-too-long
Nok Lam Chan
10/01/2024, 11:08 PMERROR tests/test_run.py:TestProjectContext:test_project_path - TypeError: KedroContext.__init__() missing 1 required positional argument: 'env'Can you pass in a value there?
env=None
?Galen Seilis
10/01/2024, 11:11 PMfoo
. Is this something to change on the Kedro end, or something wrong with my setup? (I ran kedro new
and then followed the prompts).Galen Seilis
10/01/2024, 11:12 PMfoo
?Juan Luis
10/01/2024, 11:24 PMGalen Seilis
10/01/2024, 11:25 PM