Search anything in a live python object, method or variable
Project description
About The Project
Have you ever spent hours looking for the name of a method or property of a third party library? You are sure that this method/property must exist, but you cannot find it, neither in the documentation, nor in the examples, nor on StackOverflow... You end up scrolling through the source code of the library... So frustrating!
Search'In is a tool that allows you to search in python objects as if you were on Google, just by adding a line in the middle of your code !
Getting Started
Using Search'In requires no effort at all!
Install Search'In with pip :
pip install searchin
Import Search'In in your code, by adding this line :
import searchin
To search for "name"
in a Human
class for example, just add this line :
searchin(Human, "name")
Other examples
You can search for any string in any python "entity" : variable, method, object, class, module, etc.
Search for "5"
in a tuple
searchin((1, 2, 3, 4, 5, 6, 7, 8, 9), "5")
# >>> "5" found in root.4 : 5
Search for "mean"
in the method torch.nn.functional.cross_entropy
searchin(torch.nn.functional.cross_entropy, "mean")
# >>> "mean" found in root. : def cross_entropy( [...] reduction: str = "mean", [...], label_smoothing)
Search for "grad"
in a torch.nn.Module
model = torch.nn.Linear(10, 10)
searchin(model, "grad")
# >>> "grad" found in root.bias
# >>> "grad" found in root.requires_grad_
# >>> "grad" found in root.weight
# >>> "grad" found in root.zero_grad
Advanced features
def searchin(obj,
query: str,
max_depth: int = 3,
top_k_results: int = 10,
max_iterable_length: int = 100,
get_raw_result: bool = False) -> Union[List[SearchResult], None]:
"""
Search an object for a given search term.
:param obj: The object to search in.
:param query: What to search for.
:param max_depth: The maximum depth of the recursive search.
:param top_k_results: The maximum number of results to return.
:param max_iterable_length: The maximum length of an iterable to search in.
:param get_raw_result: If True, return the raw results (of type SearchResult), else just print them.
:return: A list of search results.
"""
Contributing
(Section in english)
I want to add a lot of functionnalities to this project, but I don't have much time to work on it. Contributions are welcome!
Roadmap/todo
Task | Importance | Difficulty | Contributor on it | Description |
---|---|---|---|---|
Fuzzy match | 5/5 | 2/5 | NOBODY | e.g. : batch_size should match when searching batchsize . |
Link to implem | 5/5 | 3/5 | NOBODY | In jupyter notebooks, etc. one should be able to click results to go to implementation. |
Underline the match | 4/5 | 1/5 | NOBODY | e.g. : the printed result should be formatted like this : def cross_entropy( [...] reduction: str = "mean", [...], label_smoothing) |
Write some tests | 4/5 | 2/5 | NOBODY | Write some tests to ensure that the code is working properly. |
Find a better algorithm | 3/5 | 4/5 | NOBODY | The current algorithm is a BFS (Breadth First Search). Maybe there is a better algorithm to use. |
Searchin... animation |
3/5 | 1/5 | NOBODY | Add a cool animation when searching takes a bit of time. |
Profile code | 2/5 | 1/5 | NOBODY | Profile the code to see if we can speed it up a little. |
Add a CLI | 1/5 | 2/5 | NOBODY | Think about the design of a CLI (Command Line Interface) to use Search'In from the terminal. |
Non-Code contribution :
Task | Importance | Difficulty | Contributor on it | Description |
---|---|---|---|---|
Adding documentation | 4/5 | 1/5 | NOBODY | Add some helpful docstrings, write basic tutorials with real-life scenarios, write a wiki for other contributors to better understand the functioning of the library. |
For every todo, just click on the link to find the discussion where I describe how I would do it.
See the discussions for a full list of proposed features (and known issues).
How to contribute
Contributing is an awesome way to learn, inspire, and help others. Any contributions you make are greatly appreciated, even if it's just about styling and best practices.
If you have a suggestion that would make this project better, please fork the repo and create a pull request.
Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/YourAmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Authors
This library was created by Nicolas MICAUX.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file searchin-0.2.3.tar.gz
.
File metadata
- Download URL: searchin-0.2.3.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b92a00812370ee1fd6875e579d2c645e30413c0e296b5965953aca6b101b703 |
|
MD5 | 0e24f087dec9821aaf394c364829e33a |
|
BLAKE2b-256 | 4a26e2503eb0c806dd20271704586e42f139c1f07af2bc180decc7cd7315e8b8 |