kedro-org / kedro-plugins

First-party plugins maintained by the Kedro team.
Apache License 2.0
87 stars 76 forks source link

Default test configuration prevents using IDE debuggers #568

Open astrojuanlu opened 5 months ago

astrojuanlu commented 5 months ago

Description

With this launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug NetCDF test",
            "type": "debugpy",
            "request": "launch",
            "module": "pytest",
            "justMyCode": false,
            "args": [
                "-s",
                "--log-cli-level=DEBUG",
                "-vvv",
                "-k",
                "pass_credentials",
                "tests/netcdf/test_netcdf_dataset.py"
            ],
            "cwd": "${workspaceFolder}/kedro-datasets"
        }
    ]
}

I was being unable to do a proper debugging (VSCode would skip all me breakpoints). Then after squinting at the logs I found this:

PYDEV DEBUGGER WARNING:
sys.settrace() should not be used when the debugger is being used.
This may cause the debugger to stop working correctly.
If this is needed, please check: 
http://pydev.blogspot.com/2007/06/why-cant-pydev-debugger-work-with.html
to see how to restore the debug tracing back correctly.
Call Location:
  File "/Users/juan_cano/.micromamba/envs/kedro39-dev/lib/python3.9/site-packages/coverage/collector.py", line 348, in _installation_trace
    sys.settrace(None)

It turns out we're adding --cov in all pytest invokations:

https://github.com/kedro-org/kedro-plugins/blob/f33acbea33628abfc98a5c112e49931988f29b5a/kedro-datasets/pyproject.toml#L38-L43

Removing those lines allowed me to perform a normal debugging session.

merelcht commented 4 months ago

@astrojuanlu Do you know if this is a problem for just VSCode or other IDEs as well?

astrojuanlu commented 4 months ago

It's been a few years since I last used PyCharm but I recall this used to be a problem there as well. So it probably affects other IDEs.

noklam commented 4 months ago

This affect PyCharm too. This mainly affect maintainers/contributor because debugging a Kedro project won't have this problem. This only exists in the kedro/kedro-datasets repository