User-friendly operators
Ein zugehöriger Pull Request wurde bereits gemerged.
- #2109 von @nuclearcat — gemerged
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 20/100
Rechercherichtung
Beginne damit, das Parsen von Abfragen in der kci-Kommandozeile und die im Issue beschriebene Handhabung von Operatoren in der API-URL nachzuverfolgen, und sieh dir anschließend die MongoDB-Abfrageoperatoren als Referenz an. Eine abgeschlossene Änderung sollte über ein klar abgegrenztes Operator- und Syntaxdesign verfügen, das kombinierte Operatoren sowie die relevanten Einschränkungen der CLI oder von Attributnamen berücksichtigt, wobei sich die Beispielabfragen wie vorgesehen verhalten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
The current syntax for operators on the command line is the same as in the API URLs, with a __ separator between the attribute name and an operator. For example, to count the number of kernel revisions (checkout nodes) since the beginning of the Early Access phase:
$ ./kci node count created__gt=2023-09-04 name=checkout
38
This works, however there are a few things that could be improved:
Combining operators doesn't work
This should return the number of nodes for the 1-day period, but instead it only takes into account the 2nd query parameter:
$ kci node count created__gt=2023-09-04 created__lt=2023-09-05 name=checkout
166
Deal with attributes that have __ in their name
Some test suites might well have __ in their name or particular jobs might generate custom data including it in their attributes. While we could make it invalid and the API would be rejecting such data, we could also look for other ways to encode the operators in the URLs. At the very least, we could just make it invalid to name attributes that end with an operator name. For example, foo_bar would still be valid, and even foo__bar__baz, but not foo_gte or foo_bar_lt as gte and lt as known operators.
Consider additional operators
The current 4 operators were added out of necessity for the initial use-cases we had. A fully-fledged system would need to be able to deal with a broader range of use cases and as such more operators are likely to be required. See the list of MongoDB operators as a reference, they could all be implemented very easily since internally the API uses MongoDB (at least the comparison ones).
Probably we could already just add the ne (not equal) operator to the list, in fact it's quite surprising we got this far without needing it.
Command-line syntax
While some improvements can be made on the API side to provide features and define any constraints with attribute names, the CLI syntax offered by kci could also be made simpler. Right now, it's quite easy to forget one underscore and doing created_lt=2024 will not match anything as that's looking for an attribute called created_lt.
If we wanted to keep it as-is and just pass the search parameters to the URL, we could have a check in kci if the attribute name ends with a known operator and print a warning to the user.
On top of this, we could also provide some symbols such as <, <=, == etc. as equivalents to the operator acronyms. A sample command line would then look like this:
$ kci node count "created > 2023-09-04" "created <= 2023-09-05" name=checkout
Please note that this would involve lots of characters that aren't very usable on the command line: < and > are used for redirecting streams, ! is a magic character in most shells to do things like running a previous command and = is used by parsers for arguments that take a value. So while making the queries more human-readable on the CLI is a good idea, it doesn't seem obviously better to just use these symbols. One option would be to create an interactive parser e.g. kci shell and then any characters could be used without interfering the main OS shell.
- Vorherrschende Sprache
- Python
- Sterne
- 10
- Forks
- 21
- Ø Merge
- 22 Min.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus kernelci/kernelci-api
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
kernelci/kernelci-api#706 ·
-
Components/Maestro/API/Local instance says GET /latest/ should return some JSON, but it doesn'tEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offendocumentation
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
kernelci/kernelci-api#632 · 1 Kommentar ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
kernelci/kernelci-api#629 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
kernelci/kernelci-api#608 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
kernelci/kernelci-api#597 · 2 Kommentare ·
Alle Issues in kernelci/kernelci-api
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] Multi-day events show "Ended" while still in progressEvtl. vergeben @tarunagnihotri534 hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
data-umbrella/du-event-board#231 · 2 Kommentare ·
-
avl_automation: the generated control surface block isn't valid XML (typo in avl_out_parse.py)Evtl. vergeben @brksol hat das heute übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
PX4/PX4-gazebo-models#164 ·