Skip to content

Latest commit

 

History

History
executable file
·
184 lines (143 loc) · 9.7 KB

README.fr.md

File metadata and controls

executable file
·
184 lines (143 loc) · 9.7 KB

Contributors Stargazers Issues PyPi version Python 2 Python 3


Logo

Search'In

Cherchez ce que vous voulez dans un objet, méthode ou variable python, directement dans votre code !


Voir la démo · Report Bug

Introduction

Avez vous déjà passé des heures à chercher le nom d'une méthode ou d'une propriété d'une librairie tierce ? Vous êtes sûr que cette méthode/propriété doit exister, mais impossible de la trouver, ni dans la documentation, ni dans les exemples, ni sur StackOverflow... Vous finissez par vous résigner à scroller dans le code source de la librairie... Tellement frustrant !

Search'In est un outil qui vous permet de rechercher dans des objets python comme si vous étiez sur Google, juste en ajoutant une ligne en plein milieu de votre code !

(retour en haut)

Pour commencer

Utiliser Search'In ne recquiert aucun effort.

Installer Search'In avec pip :

pip install searchin

Importer Search'In dans votre code, en ajoutant cette ligne :

import searchin

Pour chercher "name" dans une classe Human par exemple, il suffit d'ajouter cette ligne :

searchin(Human, "name")

(back to top)

D'autres exemples

Vous pouvez chercher n'importe quelle chaîne de caractère dans n'importe quel "entité" python : variable, méthode, objet, classe, module, etc.

Chercher "5" dans un tuple

searchin((1, 2, 3, 4, 5, 6, 7, 8, 9), "5")
# >>> "5" found in root.4 : 5

Chercher "mean" dans la méthode torch.nn.functional.cross_entropy

searchin(torch.nn.functional.cross_entropy, "mean")
# >>> "mean" found in root. : def cross_entropy( [...] reduction: str = "mean", [...], label_smoothing)

Chercher "grad" dans un 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

Fonctionnalités avancées

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.
    """

(back to top)

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.
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 open issues for a full list of proposed features (and known issues).

(back to top)

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/YourAmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Auteurs

Cette librairie a été crée par Nicolas MICAUX.