feat(search): add unified search command across Kaggle content#1143
Conversation
|
Hi Steve and Bovard! |
|
/gcbrun |
|
@sridipbasu Thanks! I see what you mean about potentially changing the way the tool is used. :) I'm looking at the PR now, but it's going to take a while. I just wanted to let you know that a change to the command set won't be included in a X.Y.Z point release; it needs a X.Y.0 version. So, while I may release 2.2.4 this week, it won't include this PR. This will be in 2.3 assuming all goes well. And, one question: you mentioned "pre-existing Windows path-related failures" in tests. Are there any that are not marked as failures? I need to take a look at the known failing test and if there are any others they need to get cleaned up, too. |
stevemessick
left a comment
There was a problem hiding this comment.
This looks good, thanks. I think you should add benchmarks to the list of searchable entities. Also, I'm puzzled why comments are excluded while discussions are included. Have you checked that discussions attached to entities like notebooks and datasets are searched?
None of the images embedded in your comment above are clickable for me. Fortunately, they are of sufficient quality I can use the browser to zoom in and read them.
| """ | ||
| if not document_types: | ||
| return [] | ||
| mapping = { |
There was a problem hiding this comment.
You can eliminate most of this by using lookup_enum() instead. (Might still need to drop 's')
There was a problem hiding this comment.
Thanks! I updated this to use lookup_enum() instead of the manual mapping. I kept the small alias handling (notebook/discussion) and the plural stripping so the existing CLI behavior stays the same.
| Returns: | ||
| ListSearchContentOrderBy: The resolved enum value. | ||
| """ | ||
| mapping = { |
There was a problem hiding this comment.
Again, use lookup_enum() instead. See how 'relevance' is handled elsewhere in the code.
There was a problem hiding this comment.
Thanks! Switched this over to lookup_enum(). I only kept relevance as a special case since it doesn't have a matching enum value.
| Returns: | ||
| str: A lowercase label such as "notebook" or "discussion". | ||
| """ | ||
| labels = { |
There was a problem hiding this comment.
Honest question: does Python not have a built-in translation from enum to name?
There was a problem hiding this comment.
Ahh yes correct, updated this to use enum.name. I only kept the two overrides for KERNEL -> notebook and TOPIC -> discussion to preserve the CLI labels.
|
Addressed the review comments in the latest commit. Changes made:
Thanks for the suggestions! |
|
|
/gcbrun |
|
Earlier it showed, the branch had conflicts. I've updated and fixed it. |
|
/gcbrun |
|
/gcbrun |
|
@sridipbasu After merging your other PR I noticed this one had a merge conflict, so I fixed that. Just as a reminder, I'm still waiting on the changes I suggested in my main review (benchmarks, comments). This is looking good so far! Once we get everything caught up, if you have time to fix the tests that fail on Windows, I'd be glad to review the PR. (You probably noticed that we don't test on Windows.) |
|
I addressed the remaining feedback in the latest commit.
From what I found, For now, I kept the Thanks again for the suggestions, they definitely helped improve the implementation! |
|
/gcbrun |
stevemessick
left a comment
There was a problem hiding this comment.
Thanks! This is going to be really useful, I think.




Summary
This PR adds a new top-level command:
kaggle search "<query>"It provides a unified way to search across multiple Kaggle content types from a single command, including datasets, competitions, notebooks, models, users, and discussions.
Motivation
Currently, searching in the Kaggle CLI is only available through individual commands such as:
This means users have to run multiple commands when they are not sure where the content they are looking for exists.
For example, searching for "Gemma" may require checking models, notebooks, datasets, and competitions separately. A unified search command makes content discovery much easier from the terminal.
What this adds
A new command:
kaggle search "<query>"Supported features
--type--mineExample usage
Implementation
This feature uses the existing
SearchApiService.list_entitiesendpoint available throughkagglesdk.The CLI builds a
ListEntitiesRequest, sends it through the existing authenticated client, and normalizes the mixed search results so they can reuse the existing output formatting for table, CSV, and JSON outputs.By default, the search is limited to the CLI-supported content types (datasets, competitions, notebooks, models, users, and discussions). This keeps the results focused on content that the CLI can represent and use directly while still using the backend's canonical ranking.
Testing
Added tests covering:
The new tests pass, and the existing test suite continues to pass except for the pre-existing Windows path-related failures already present on
main.Backward Compatibility
This change is fully additive and does not modify any existing commands or flags.
Future Improvements
Possible future enhancements include: