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

Refactor(pyavd): Adding path attribute to the validation error for removed keys #4688

Conversation

Shivani-gslab
Copy link
Contributor

@Shivani-gslab Shivani-gslab commented Nov 6, 2024

Change Summary

In https://github.com/aristanetworks/avd/blob/devel/python-avd/pyavd/avd_schema_tools.py#L67,
the AvdDeprecationWarning is converted to AvdValidationError for the removed keys.
It does not have path attribute which is needed for highlighting errors in AVD VSCode extension.

Updating the conversion to get the path attribute.

Related Issue(s)

Fixes #https://github.com/aristanetworks/vscode-avd/issues/5

Component(s) name

pyavd

Proposed changes

Adding to_validation_error method to AvdDeprecationWarning for error conversion along with getting the path attribute.
Using this method in schema tools for getting validation error.

How to test

Checklist

User Checklist

  • N/A

Repository Checklist

  • My code has been rebased from devel before I start
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation and documentation have been updated accordingly.
  • I have updated molecule CI testing accordingly. (check the box if not applicable)

Copy link

github-actions bot commented Nov 6, 2024

Review docs on Read the Docs

To test this pull request:

# Create virtual environment for this testing below the current directory
python -m venv test-avd-pr-4688
# Activate the virtual environment
source test-avd-pr-4688/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/Shivani-gslab/avd.git@fix_pyavd_validation_error#subdirectory=python-avd" --force
# Point Ansible collections path to the Python virtual environment
export ANSIBLE_COLLECTIONS_PATH=$VIRTUAL_ENV/ansible_collections
# Install Ansible collection
ansible-galaxy collection install git+https://github.com/Shivani-gslab/avd.git#/ansible_collections/arista/avd/,fix_pyavd_validation_error --force
# Optional: Install AVD examples
cd test-avd-pr-4688
ansible-playbook arista.avd.install_examples

@Shivani-gslab Shivani-gslab force-pushed the fix_pyavd_validation_error branch 2 times, most recently from 0276c19 to 6cf77ed Compare November 6, 2024 06:34
@Shivani-gslab Shivani-gslab changed the title Refactor(pyavd): Adding to_validation_error method to AvdDeprecationWarning Refactor(pyavd): Adding path attribute to the validation error for removed keys Nov 6, 2024
@Shivani-gslab Shivani-gslab marked this pull request as ready for review November 6, 2024 08:56
@Shivani-gslab Shivani-gslab requested review from a team as code owners November 6, 2024 08:56
Copy link
Contributor

@ClausHolbechArista ClausHolbechArista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Only a minor suggestion to avoid later surprises.

@ClausHolbechArista ClausHolbechArista added the one approval This PR has one approval and is only missing one more. label Nov 6, 2024
Copy link
Contributor

@Vibhu-gslab Vibhu-gslab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Shivani-gslab Shivani-gslab marked this pull request as draft November 7, 2024 07:40
@Shivani-gslab Shivani-gslab marked this pull request as ready for review November 7, 2024 07:42
Copy link

sonarcloud bot commented Nov 7, 2024

@ClausHolbechArista ClausHolbechArista merged commit f21aa4a into aristanetworks:devel Nov 7, 2024
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
one approval This PR has one approval and is only missing one more. rn: Refactor(pyavd)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants