-
Notifications
You must be signed in to change notification settings - Fork 29
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
chore: Add vscode python debugger for anta code #908
base: main
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
CodSpeed Performance ReportMerging #908 will not alter performanceComparing Summary
|
@@ -1,14 +0,0 @@ | |||
{ | |||
"ruff.enable": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm @mtache ok for you if this goes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reintroduce file
tests/units/cli/test__init__.py
Outdated
@@ -34,10 +35,11 @@ def test_cli_error_missing(capsys: pytest.CaptureFixture[Any]) -> None: | |||
"""Test ANTA errors out when anta[cli] was not installed.""" | |||
with patch.dict(sys.modules) as sys_modules, patch("builtins.__import__", import_mock): | |||
del sys_modules["anta.cli._main"] | |||
del sys_modules["anta.cli.console"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this one needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Work in progress to fix pytest error
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
.vscode/launch.json
Outdated
"console": "integratedTerminal", | ||
"request": "launch", | ||
"module": "anta.cli", | ||
"args": [ "nrfu", "-c", "${workspaceFolder}/.vscode/nrfu.yml", "-i", "${workspaceFolder}/.vscode/inventory.yml", "text"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"args": [ "nrfu", "-c", "${workspaceFolder}/.vscode/nrfu.yml", "-i", "${workspaceFolder}/.vscode/inventory.yml", "text"], | |
"args": [ "nrfu", "text"], |
I think we should let the user run NRFU with his own environment variables. We wouldn't need env
below and maintain the inventory.yml
+ nrfu.yml
files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by introducing management via envFile
logging.error( | ||
"The ANTA command line client could not run because the required " | ||
"dependencies were not installed.\nMake sure you've installed " | ||
"everything with: pip install 'anta[cli]'" | ||
) | ||
if __DEBUG__: | ||
logging.debug("The caught exception was: %s", exception) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer being triggered as before:
BEFORE:
(.pyavd_cli) ~/git_projects/anta (main ✗) anta nrfu json
The ANTA command line client could not run because the required dependencies were not installed.
Make sure you've installed everything with: pip install 'anta[cli]'
(.pyavd_cli) ~/git_projects/anta (main ✗) ANTA_DEBUG=true anta nrfu json
The ANTA command line client could not run because the required dependencies were not installed.
Make sure you've installed everything with: pip install 'anta[cli]'
The caught exception was: cannot import name 'ResultManager' from partially initialized module 'anta.result_manager.models' (most likely due to a circular import) (/home/cbaillar/git_projects/anta/anta/result_manager/models.py)
AFTER:
(.pyavd_cli) ~/git_projects/anta (chore/python-debugger ✗) ANTA_DEBUG=true anta nrfu json
Traceback (most recent call last):
File "/home/cbaillar/.pyenv/versions/3.12.3/envs/.anta/bin/anta", line 5, in <module>
from anta.cli import cli
ImportError: cannot import name 'cli' from 'anta.cli' (/home/cbaillar/git_projects/anta/anta/cli/__init__.py)
Before we were going from ._main import anta, cli
, and now from ._main import cli
- cli is imported first so maybe that's causing the different behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conflicts have been resolved. A maintainer will review the pull request shortly. |
Description
Implement VSCode Python debugger configuration to run ANTA CLI in debug mode.
This mechanism gives you following options:
And more
Default configuration is based on the following files:
.vscode/inventory.yml
: List of hosts to use in anta. Use ATD IP addressschema.
.vscode/nrfu.yml
: List of NRFU tests to run.Checklist:
pre-commit run
)tox -e testenv
)