-
Notifications
You must be signed in to change notification settings - Fork 5
Fix parameter_match check, to support non-normalized data #90
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
Conversation
("arista_eos", "show_version", "[*].[$image$,image]", {"image": "4.14.7M"}, True), | ||
("arista_eos", "show_version", "[*].[$image$,image]", {"image": "no-match"}, False), | ||
("cisco_ios", "show_version", "[*].[$version$,version]", {"version": "12.2(54)SG1"}, True), | ||
("cisco_ios", "show_version", "[*].[$version$,version]", {"version": "no-match"}, False), | ||
("cisco_nxos", "show_version", "[*].[$os$,os]", {"os": "6.1(2)I3(1)"}, True), | ||
("cisco_nxos", "show_version", "[*].[$os$,os]", {"os": "no-match"}, False), |
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.
That was very unnatural workaround for parameter_match. Now fixed.
@@ -51,41 +51,41 @@ def parameter_evaluator(values: Mapping, parameters: Mapping, mode: str) -> Dict | |||
Dictionary with all the items that have some value not matching the expectations from parameters | |||
""" | |||
if not isinstance(values, list): | |||
raise TypeError("Something went wrong during jmespath parsing. 'values' must be of type List.") |
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.
Jmespath parsing is now optional.
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.
Question around this. If JMSPATH is now optional, how the library will understand when is required and when is not?
# inner_value: [{'peerAddress': '7.7.7.7', 'localAsn': '65130.1101', 'linkType': 'externals'}] | ||
value = list(value.values())[0] | ||
else: | ||
inner_key = index |
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.
what is the value in this case?
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.
An element from the top for loop, where values is a function argument.
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.
If data normalisation is detected, then reassign value from inner element.
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.
Jmespath parsing is now optional.
I believe this answering to my question above (?)
@pszulczewski Please update tests for |
@lvrfrc87 test added requested. |
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.
Just one point from my side. If you can clarify we should then be good to go
@@ -51,41 +51,41 @@ def parameter_evaluator(values: Mapping, parameters: Mapping, mode: str) -> Dict | |||
Dictionary with all the items that have some value not matching the expectations from parameters | |||
""" | |||
if not isinstance(values, list): | |||
raise TypeError("Something went wrong during jmespath parsing. 'values' must be of type List.") |
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.
Question around this. If JMSPATH is now optional, how the library will understand when is required and when is not?
# inner_value: [{'peerAddress': '7.7.7.7', 'localAsn': '65130.1101', 'linkType': 'externals'}] | ||
value = list(value.values())[0] | ||
else: | ||
inner_key = index |
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.
Jmespath parsing is now optional.
I believe this answering to my question above (?)
@lvrfrc87 there is detection is data has been normalized. |
LGTM! |
* Update readme to start with use cases (#84) * Update readme to start with use cases * Apply suggestions from code review Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> * Update README.md Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> * Doc update (#87) * Fix operator checks to follow other check_type logic. (#85) * Fix operator checks to follow other check_type logic. * Add new release 0.0.2 Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> * Implement `ge` and `le` operator type (#89) * Release 0.0.2 (#88) * Update readme to start with use cases (#84) * Update readme to start with use cases * Apply suggestions from code review Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> * Update README.md Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> * Doc update (#87) * Fix operator checks to follow other check_type logic. (#85) * Fix operator checks to follow other check_type logic. * Add new release 0.0.2 Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> Co-authored-by: Christian Adell <christian.adell@networktocode.com> Co-authored-by: Ken Celenza <ken@celenza.org> Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> * add operator ge and le * fix validate tests Co-authored-by: Christian Adell <christian.adell@networktocode.com> Co-authored-by: Ken Celenza <ken@celenza.org> Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> * Fix parameter_match check, to support non-normalized data (#90) * Fix parameter_match check, to support non-normalized data * Add test * Update tests. * remove test print Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> * Update mypy * Bugfix to data normalization * Fix ref_key parsing * Update docs * Issue 92 (#98) * Base-line tests for future refactor. * Refactor to simplify code. * Implement issue #92 * Bump certifi from 2022.9.24 to 2022.12.7 (#95) Bumps [certifi](https://github.com/certifi/python-certifi) from 2022.9.24 to 2022.12.7. - [Release notes](https://github.com/certifi/python-certifi/releases) - [Commits](certifi/python-certifi@2022.09.24...2022.12.07) --- updated-dependencies: - dependency-name: certifi dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Christian Adell <christian.adell@networktocode.com> Co-authored-by: Ken Celenza <ken@celenza.org> Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Update readme to start with use cases (#84) * Update readme to start with use cases * Apply suggestions from code review Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> * Update README.md Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> * Doc update (#87) * Fix operator checks to follow other check_type logic. (#85) * Fix operator checks to follow other check_type logic. * Add new release 0.0.2 Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> * Implement `ge` and `le` operator type (#89) * Release 0.0.2 (#88) * Update readme to start with use cases (#84) * Update readme to start with use cases * Apply suggestions from code review Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> * Update README.md Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> * Doc update (#87) * Fix operator checks to follow other check_type logic. (#85) * Fix operator checks to follow other check_type logic. * Add new release 0.0.2 Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> Co-authored-by: Christian Adell <christian.adell@networktocode.com> Co-authored-by: Ken Celenza <ken@celenza.org> Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> * add operator ge and le * fix validate tests Co-authored-by: Christian Adell <christian.adell@networktocode.com> Co-authored-by: Ken Celenza <ken@celenza.org> Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> * Fix parameter_match check, to support non-normalized data (#90) * Fix parameter_match check, to support non-normalized data * Add test * Update tests. * remove test print Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> * Update mypy * Bugfix to data normalization * Fix ref_key parsing * Update docs * Issue 92 (#98) * Base-line tests for future refactor. * Refactor to simplify code. * Implement issue #92 * Bump certifi from 2022.9.24 to 2022.12.7 (#95) Bumps [certifi](https://github.com/certifi/python-certifi) from 2022.9.24 to 2022.12.7. - [Release notes](https://github.com/certifi/python-certifi/releases) - [Commits](certifi/python-certifi@2022.09.24...2022.12.07) --- updated-dependencies: - dependency-name: certifi dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update version and changelog * update poetry lock * Update changelog * Issue 94 & 91 (#100) * Baseline unittests * Fix issue #94 * Remove test print * Fix issue #91 * Relax deepdiff dependency. * Update pyproject.toml Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> * Update poetry.lock * Relase v0.0.4 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Christian Adell <christian.adell@networktocode.com> Co-authored-by: Ken Celenza <ken@celenza.org> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> Co-authored-by: Federico87 <15066806+lvrfrc87@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Network to Code <federico.olivieri@networktocode.com> Co-authored-by: Leo Kirchner <leo.kirchner98@gmail.com> Co-authored-by: Leo Kirchner <Kircheneer@users.noreply.github.com>
* Update readme to start with use cases (#84) * Update readme to start with use cases * Apply suggestions from code review Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> * Update README.md Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> * Doc update (#87) * Fix operator checks to follow other check_type logic. (#85) * Fix operator checks to follow other check_type logic. * Add new release 0.0.2 Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> * Implement `ge` and `le` operator type (#89) * Release 0.0.2 (#88) * Update readme to start with use cases (#84) * Update readme to start with use cases * Apply suggestions from code review Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> * Update README.md Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> * Doc update (#87) * Fix operator checks to follow other check_type logic. (#85) * Fix operator checks to follow other check_type logic. * Add new release 0.0.2 Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> Co-authored-by: Christian Adell <christian.adell@networktocode.com> Co-authored-by: Ken Celenza <ken@celenza.org> Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> * add operator ge and le * fix validate tests Co-authored-by: Christian Adell <christian.adell@networktocode.com> Co-authored-by: Ken Celenza <ken@celenza.org> Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> * Fix parameter_match check, to support non-normalized data (#90) * Fix parameter_match check, to support non-normalized data * Add test * Update tests. * remove test print Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> * Update mypy * Bugfix to data normalization * Fix ref_key parsing * Update docs * Issue 92 (#98) * Base-line tests for future refactor. * Refactor to simplify code. * Implement issue #92 * Bump certifi from 2022.9.24 to 2022.12.7 (#95) Bumps [certifi](https://github.com/certifi/python-certifi) from 2022.9.24 to 2022.12.7. - [Release notes](https://github.com/certifi/python-certifi/releases) - [Commits](certifi/python-certifi@2022.09.24...2022.12.07) --- updated-dependencies: - dependency-name: certifi dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update version and changelog * update poetry lock * Update changelog * Issue 94 & 91 (#100) * Baseline unittests * Fix issue #94 * Remove test print * Fix issue #91 * Relax deepdiff dependency. * Update pyproject.toml Co-authored-by: Patryk Szulczewski <patryk@szulczewski.eu> * Update poetry.lock * Relase v0.0.4 * Release v0.0.4 (#105) --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Christian Adell <christian.adell@networktocode.com> Co-authored-by: Ken Celenza <ken@celenza.org> Co-authored-by: Stephen Corry <stephen.corry@networktocode.com> Co-authored-by: Patryk Szulczewski <patryk.szulczewski@networktocode.com> Co-authored-by: Federico87 <15066806+lvrfrc87@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Network to Code <federico.olivieri@networktocode.com> Co-authored-by: Leo Kirchner <leo.kirchner98@gmail.com> Co-authored-by: Leo Kirchner <Kircheneer@users.noreply.github.com>
While working on some Napalm checks, another time I faced issues that some of checks are expecting only normalized data with jmespath anchored key. As this is limiting usability of the lib, hence the fix for parameter_match.
It still supports normalized data, but now also supports flat dictionaries.
importlib-metadata
was failing for flake8 checks. New release 5.0.0 is not backwards compatible so keeping it below 5.0.0 for the time being.