Skip to content

Change core and lib search commands to use fuzzy search #1193

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

Merged
merged 6 commits into from
Feb 25, 2021

Conversation

silvanocerza
Copy link
Contributor

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce?

Enhances core search and lib search commands and related gRPC interface functions by introducing fuzzy search.

  • What is the current behavior?

As of now core search and lib search both do a plain text matching on several platforms or libraries parameters to find results, this required the user to write exactly a string that matched one of those parameters.

This is frustrating since even a missing space or underscore would make the search fail.

For example calling lib search with Arduino mkr iot carrier or Arduinomkriotcarrier would never return the library Arduino_MKRIoTCarrier.

Or calling core search with yun instead of yún with the correct accent would never return the arduino:avr platform.

  • What is the new behavior?

A fuzzy search is now done when calling core search and lib search, this way the user won't be required to write exactly the string to search but it will manipulated to find matches. Accented chars are normalized, missing chars or typos are handled, and things like this. It's not magical but better than before.

Now calling lib search with Arduino mkr iot carrier or Arduinomkriotcarrier will return the library Arduino_MKRIoTCarrier.

Also calling core search with yun without an accent will return the arduino:avr platform.

This also affects the gRPC interface.

Nope.

  • Other information:

None.


See how to contribute

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

It seems like it's taking "fuzzy" a bit too far:

$ arduino-cli core search yun
Updating index: package_index.json downloaded
Updating index: package_index.json.sig downloaded
ID                Version Name
Microsoft:win10   1.1.2   Windows 10 Iot Core
arduino-beta:mbed 1.3.1   [DEPRECATED] Arduino mbed-enabled Boards
arduino:avr       1.8.3   Arduino AVR Boards
arduino:samd      1.8.11  Arduino SAMD Boards (32-bits ARM Cortex-M0+)

For example, I don't see what would give a match to "yun" in the "Windows 10 Iot Core" platform entry:

Click to expand
{
  "name": "Microsoft",
  "maintainer": "Microsoft.IoT",
  "websiteURL": "https://github.com/ms-iot/iot-utilities/tree/master/IotCoreAppDeployment/ArduinoIde/",
  "email": "bfjelds@microsoft.com",
  "help": {
    "online": "http://developer.microsoft.com/en-us/windows/iot/IotCoreAppDeployment_ArduinoIde.htm"
  },
  "platforms": [
    {
      "name": "Windows 10 Iot Core",
      "architecture": "win10",
      "version": "1.0.0",
      "category": "Contributed",
      "help": {
        "online": "http://developer.microsoft.com/en-us/windows/iot/IotCoreAppDeployment_ArduinoIde.htm"
      },
      "url": "https://github.com/ms-iot/iot-utilities/raw/master/IotCoreAppDeployment/ArduinoIde/release/win10_iotcore-1.0.0_ide-1.6.6.zip",
      "archiveFileName": "win10_iotcore-1.0.0_ide-1.6.6.zip",
      "checksum": "SHA-256:ed1b42b396217e242cd3a5b597ad5dad5957cb8117dd0f972376bafab7d8a0e5",
      "size": "47325480",
      "boards": [
        {"name": "Windows 10 IoT Core"}
      ],
      "toolsDependencies":[]
    },
    {
      "name": "Windows 10 Iot Core",
      "architecture": "win10",
      "version": "1.1.0",
      "category": "Contributed",
      "help": {
        "online": "http://developer.microsoft.com/en-us/windows/iot/IotCoreAppDeployment_ArduinoIde.htm"
      },
      "url": "https://github.com/ms-iot/iot-utilities/raw/master/IotCoreAppDeployment/ArduinoIde/release/win10_iotcore-1.1.0_ide-1.6.6.zip",
      "archiveFileName": "win10_iotcore-1.1.0_ide-1.6.6.zip",
      "checksum": "SHA-256:683dcb0a72e80b9d21117f6471e0860d8cc35cd9b86557ba6fd1ed255952413e",
      "size": "48316890",
      "boards": [
        {"name": "Windows 10 IoT Core"}
      ],
      "toolsDependencies":[]
    },
    {
      "name": "Windows 10 Iot Core",
      "architecture": "win10",
      "version": "1.1.1",
      "category": "Contributed",
      "help": {
        "online": "http://ms-iot.github.io/content/en-US/win10/IotCoreAppDeployment_ArduinoIde.htm"
      },
      "url": "https://github.com/ms-iot/iot-utilities/raw/master/IotCoreAppDeployment/ArduinoIde/release/win10_iotcore-1.1.1_ide-1.6.11.zip",
      "archiveFileName": "win10_iotcore-1.1.1_ide-1.6.11.zip",
      "checksum": "SHA-256:f455f2829164065faacde141b3c15604c51bb79b6874d55d1124c66aae372693",
      "size": "48317624",
      "boards": [
        {"name": "Windows 10 IoT Core"}
      ],
      "toolsDependencies":[]
    },
    {
      "name": "Windows 10 Iot Core",
      "architecture": "win10",
      "version": "1.1.2",
      "category": "Contributed",
      "help": {
        "online": "http://ms-iot.github.io/content/en-US/win10/IotCoreAppDeployment_ArduinoIde.htm"
      },
      "url": "https://github.com/ms-iot/iot-utilities/raw/master/IotCoreAppDeployment/ArduinoIde/release/win10_iotcore-1.1.2_ide-1.6.11.zip",
      "archiveFileName": "win10_iotcore-1.1.2_ide-1.6.11.zip",
      "checksum": "SHA-256:b1c9956b46f33bcebb7f500d29931b19ed4723c713ac0439681ea1fb172722d1",
      "size": "48317648",
      "boards": [
        {"name": "Windows 10 IoT Core"}
      ],
      "toolsDependencies":[]
    }
  ],
  "tools":[]
}

@ubidefeo
Copy link

@per1234 I tested this while in a chat with @silvanocerza and I got to the same conclusion.
He wants to try something tomorrow morning and I hope it works :)

Copy link

@ubidefeo ubidefeo left a comment

Choose a reason for hiding this comment

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

pulled
built
tested
approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants