Skip to content
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

feat/add search command (fix #230) #244

Merged
merged 11 commits into from
Aug 12, 2023

Conversation

Wackyator
Copy link
Contributor

@Wackyator Wackyator commented Jul 31, 2023

Add search subcommand

➜ pixi search python -c bioconda -c conda-forge
Package                                  Version             Channel            
python                                   3.11.4              conda-forge        
ipython                                  8.14.0              conda-forge        
spython                                  0.3.0               conda-forge        
bpython                                  0.24                conda-forge        
qpython                                  2.0.0               conda-forge        
vpython                                  7.6.4               conda-forge        
lpython                                  0.19.0              conda-forge        
pythonpy                                 0.4.11              bioconda           
pythonds                                 1.2.1               conda-forge        
rlpython                                 0.10.3              conda-forge        
wxpython                                 4.2.1               conda-forge        
kb-python                                0.27.3              bioconda           
bx-python                                0.10.0              bioconda           
pythonnet                                2.3.0               bioconda           
dnspython                                2.4.2               conda-forge   

@Wackyator
Copy link
Contributor Author

This command is currently not in global namepace but works like a global command, not utilising the pixi.toml file, might have to change that. Implementation also includes couple of TODOs and doubts, would like comments over them.

@Wackyator Wackyator changed the title feat/add search command (#230) feat/add search command (fix #230) Jul 31, 2023
@ruben-arts
Copy link
Contributor

He @Wackyator,
First off! Thank you, we really appreciate the work you put in! This is a great idea! 💯
The implementation is not yet useful enough to merge like this. The similarity comparison + the sort is not friendly enough on package names in my opinion.

Some examples:

➜ pixi search rattler # Going for rattler-build
conda-forge/r-ggpattern: 1.0.1 # Expecting it first
conda-forge/r-scatterd3: 1.0.1
conda-forge/pattern: 3.6.0
conda-forge/rat: 3.0.1
conda-forge/rathole: 0.4.8
conda-forge/r-paletteer: 1.5.0
conda-forge/rattler-build: 0.3.1
conda-forge/r-later: 1.3.1
conda-forge/r-rattle: 5.5.1
➜ pixi search rerun # going for rerun-sdk
conda-forge/r-refund: 0.1_32 # expecting it first
conda-forge/faerun: 0.3.20
conda-forge/reprounzip: 1.2.1
conda-forge/returns: 0.21.0
conda-forge/r-etrunct: 0.1
conda-forge/rerun-sdk: 0.8.0
conda-forge/redun: 0.16.1
❯ pixi search plotjuggler -c robostack # Searching for ros-noetic-plotjuggler
  × Could not find plotjuggler

Personally I would like it if it supported simple glob logic (*) but more importantly for the first iteration is search for the direct sub-string. If that doesn't give any or to little results, run the fuzzy search as a second step.

For example the conda search does give these results:

➜ conda search rerun
Loading channels: done
No match found for: rerun. Search: *rerun*
# Name                       Version           Build  Channel             
pytest-rerunfailures             7.0            py_0  conda-forge         
pytest-rerunfailures             8.0            py_0  conda-forge         
pytest-rerunfailures             9.0            py_0  conda-forge         
pytest-rerunfailures             9.1            py_0  conda-forge         
pytest-rerunfailures           9.1.1            py_0  conda-forge         
pytest-rerunfailures            10.0    pyhd8ed1ab_0  conda-forge         
pytest-rerunfailures            10.1    pyhd8ed1ab_0  conda-forge         
pytest-rerunfailures            10.2    pyhd8ed1ab_0  conda-forge         
pytest-rerunfailures            10.3    pyhd8ed1ab_0  conda-forge         
pytest-rerunfailures            11.0    pyhd8ed1ab_0  conda-forge         
pytest-rerunfailures            11.1    pyhd8ed1ab_0  conda-forge         
pytest-rerunfailures          11.1.1    pyhd8ed1ab_0  conda-forge         
pytest-rerunfailures          11.1.2    pyhd8ed1ab_0  conda-forge         
pytest-rerunfailures            12.0    pyhd8ed1ab_0  conda-forge         
rerun-sdk                      0.7.0 py310hc6cd4ac_0  conda-forge         
rerun-sdk                      0.7.0  py38h17151c0_0  conda-forge         
rerun-sdk                      0.7.0  py39h3d6467e_0  conda-forge         
rerun-sdk                      0.8.0 py310hc6cd4ac_0  conda-forge         
rerun-sdk                      0.8.0  py38h17151c0_0  conda-forge         
rerun-sdk                      0.8.0  py39h3d6467e_0  conda-forge   

➜ conda search plotj -c robostack
Loading channels: done
No match found for: plotj. Search: *plotj*
# Name                       Version           Build  Channel             
ros-humble-plotjuggler           3.4.4  py39ha0dc6a7_0  robostack-humble    
ros-humble-plotjuggler           3.4.5  py39ha0dc6a7_0  robostack-humble    
ros-humble-plotjuggler           3.5.1 py310h44ee79f_3  robostack-staging   
ros-humble-plotjuggler           3.5.1  py39h1ac8cb3_1  robostack-humble    
ros-humble-plotjuggler-msgs           0.2.3 py310h7c61026_3  robostack-staging   
ros-humble-plotjuggler-msgs           0.2.3  py39h6be7e7a_1  robostack-humble    
ros-humble-plotjuggler-msgs           0.2.3  py39hd78aa24_0  robostack-humble    
ros-humble-plotjuggler-ros           1.5.1  py39h3280fdf_0  robostack-humble    
ros-humble-plotjuggler-ros           1.7.1  py39h8299418_1  robostack-humble    
ros-humble-plotjuggler-ros           1.7.3 py310ha259436_3  robostack-staging   
ros-melodic-plotjuggler           2.8.3  py36h9320cb6_1  robostack           
ros-melodic-plotjuggler-msgs           0.1.1  py36h831f99a_1  robostack           
ros-noetic-plotjuggler           3.0.6  py38h67fa3ea_4  robostack           
ros-noetic-plotjuggler           3.1.0  py38hec4e12b_6  robostack           
ros-noetic-plotjuggler           3.5.0 py39ha0dc6a7_14  robostack           
ros-noetic-plotjuggler           3.5.1 py39ha0dc6a7_14  robostack           
ros-noetic-plotjuggler           3.6.0 py39h53b1bd3_15  robostack-staging   
ros-noetic-plotjuggler           3.6.0 py39h864de9f_14  robostack           
ros-noetic-plotjuggler-msgs           0.1.1  py38he9ab703_4  robostack           
ros-noetic-plotjuggler-msgs           0.1.1  py38he9ab703_6  robostack           
ros-noetic-plotjuggler-msgs           0.2.1 py39h6fdeb60_14  robostack           
ros-noetic-plotjuggler-msgs           0.2.1 py39hac30774_15  robostack-staging   
ros-noetic-plotjuggler-ros           1.0.0  py38h4fa06b8_4  robostack           
ros-noetic-plotjuggler-ros           1.1.0  py38h4fa06b8_6  robostack           
ros-noetic-plotjuggler-ros           1.7.0 py39h3280fdf_14  robostack           
ros-noetic-plotjuggler-ros           1.7.0 py39hd1c2957_15  robostack-staging   

Additionally, a super helpful message would be to add the pixi search command to the error of a failed solve where it couldn't find the name in the channels specified. I wouldn't require it for this PR but would like your idea on it.

Looking forward to your response!

@Wackyator
Copy link
Contributor Author

Wackyator commented Aug 1, 2023

@ruben-arts I've made some changes to the searching and sorting logic a little. It now tries to look for a direct substring first and if there are no results then tries to fuzzy search. The output now goes from most relevant to least relevant results opposed to the earlier least relevant to most relevant. Could you please elaborate more on the last part about helpful messages? I didn't quite get it.

@ruben-arts
Copy link
Contributor

Much better!
Now the substring search is first I would make the simularity required to get a result lower to allow for simple typo's to be found. Like pixi search -c robostack plotjugler should find the ros-noetic-plotjuggler and ros-humble-plotjuggler.

Also the result should be a little more readable. Here is an idea:

Package name       Latest version                Channel
r-ggpattern        1.0.1                     conda-forge
r-scatterd         1.0.1                     conda-forge
pattern            3.6.0                     conda-forge
rat                3.0.1                     conda-forge
rathole            0.4.8                     conda-forge
r-paletteer        1.5.0                     conda-forge

Another idea would be that if you are in a pixi project that you use the channels defined in the toml.
So if the pixi.toml includes channels = ["conda-forge", "robostack"] that it searches in both channels automatically.

Could you please elaborate more on the last part about helpful messages? I didn't quite get it.

If I run pixi add pyton It could be cool to add a help that says something like:

> pixi add pyton
Could not find 'pyton' in repodata
Help: try to find it using: 
     pixi search pyton 

@Wackyator
Copy link
Contributor Author

These changes make sense, will add these.

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

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

You're fast!

src/cli/search.rs Outdated Show resolved Hide resolved
src/cli/search.rs Outdated Show resolved Hide resolved
src/cli/search.rs Show resolved Hide resolved
src/cli/search.rs Show resolved Hide resolved
@Wackyator Wackyator requested a review from ruben-arts August 1, 2023 16:39
@Wackyator
Copy link
Contributor Author

You're fast!

That's what she said

src/cli/search.rs Outdated Show resolved Hide resolved
src/cli/search.rs Outdated Show resolved Hide resolved
@Wackyator Wackyator requested a review from ruben-arts August 12, 2023 07:54
Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

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

This is really good!

@ruben-arts ruben-arts merged commit 8a73d86 into prefix-dev:main Aug 12, 2023
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.

2 participants