You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While evaluating using Genie with Netmiko I discovered that I was able to use abbreviated syntax such as sh ip int instead of show ip interface. However, if I did sh ip int br it would not work. After doing some digging it looks like the _fuzzy_search_command function was raising an exception and Netmiko was just swallowing it:
Search for 'sh ip int br' is ambiguous. Please be more specific in your keywords.
Results matched:
> show ip interface brief
> show ip interface {interface}
It looks like this happens because the score weight for a partial match (100) is the same as for a variable (100).
This also causes some interesting anomalies any time the position of a token in the command could be either syntax or a variable.
Even though transceive is over 90% of transceiver the function instead returns the parser with a variable instead of a partial syntax match.
My initial thought was maybe weighing partial syntax as slightly higher (101) than variables, but that broke down when doing commands like show ip prefix-list as ip is short for ipv6 even though it was meant to match on show {af} prefix-list instead. This can probably be overcome by changing the show {af} prefix-list (and all similar show {af} commands) to instead use exact syntax of show ip/show ipv6 instead of the {af} variable, but there may be other similar issues by changing the weight of partial matches that aren't apparent. I only was able to easily identify that discrepancy due to a unit test written for it.
The text was updated successfully, but these errors were encountered:
After reviewing further it seems that I should be using fuzzy=True. As this flag is not exposed in Netmiko, maybe this is better handled as an issue in that repo to expose the option.
I'll leave this issue open for now if anyone else has any input on how to better handle partial syntax matches without explicitly enabling fuzzy.
While evaluating using Genie with Netmiko I discovered that I was able to use abbreviated syntax such as
sh ip int
instead ofshow ip interface
. However, if I didsh ip int br
it would not work. After doing some digging it looks like the _fuzzy_search_command function was raising an exception and Netmiko was just swallowing it:It looks like this happens because the score weight for a partial match (100) is the same as for a variable (100).
This also causes some interesting anomalies any time the position of a token in the command could be either syntax or a variable.
For example:
Even though
transceive
is over 90% oftransceiver
the function instead returns the parser with a variable instead of a partial syntax match.My initial thought was maybe weighing partial syntax as slightly higher (101) than variables, but that broke down when doing commands like
show ip prefix-list
asip
is short foripv6
even though it was meant to match onshow {af} prefix-list
instead. This can probably be overcome by changing the show {af} prefix-list (and all similarshow {af}
commands) to instead use exact syntax ofshow ip
/show ipv6
instead of the{af}
variable, but there may be other similar issues by changing the weight of partial matches that aren't apparent. I only was able to easily identify that discrepancy due to a unit test written for it.The text was updated successfully, but these errors were encountered: