• 
      

    Refactor Whoosh and Elasticsearch support into pluggable backends

    Review Request #8254 — Created June 21, 2016 and submitted

    Information

    Review Board
    release-3.0.x
    be9ff7a...

    Reviewers

    A previous patch introduced support for Elasticsearch instead of Whoosh
    as an alternative search engine backend. Now, both Whoosh and
    Elasticsearch are provided as SearchBackends and we produce the search
    configuration form dynamically based on what search backends are
    available.

    We now use a registry to manage these backends. Extensions can now
    register additional search backends (such as for Solr or other
    Haystack-supported backends) through this interface.

    The search settings have been moved out of the general settings into its
    own form as the logic just for the form generation was getting rather
    complicated.

    • Ran unit tests.
    • Verified the settings form worked correctly.

    Description From Last Updated

    Can you make this field longer?

    chipx86chipx86

    Can you make this field longer?

    chipx86chipx86

    dddd

    QH qhr

    noqa?

    daviddavid

    Returns?

    daviddavid

    Missing a period. At first I was going to say this should say "Form," but it's managing multiple forms. Can …

    chipx86chipx86

    I think maybe, "If enabled, a search field will be provided for ..."

    chipx86chipx86

    "review requests, diffs, and users."

    chipx86chipx86

    This is redundant. We can get rid of it.

    chipx86chipx86

    This is redundant. We can get rid of it.

    chipx86chipx86

    Missing a description.

    chipx86chipx86

    "... for the base form and every search engine settings form.""" Which I'm not sure we want, actually. Probably just …

    chipx86chipx86

    This is missing a "Returns".

    chipx86chipx86

    Let's expand on the error message to make it more helpful: The search engine "%s" could not be found. If …

    chipx86chipx86

    Missing a "Returns".

    chipx86chipx86

    Missing docs.

    chipx86chipx86

    Let's add the same comment here that we have on other forms: # Reload any important changes into the Django …

    chipx86chipx86

    We're going to need to migrate this setting.

    chipx86chipx86

    Same error as above.

    chipx86chipx86

    Missing docs.

    chipx86chipx86

    Let's pass in files as well, in case we have some backend in the future that requires some uploaded license …

    chipx86chipx86

    We should have a docstring at the top of this file.

    chipx86chipx86

    We should have a docstring for this file.

    chipx86chipx86

    Missing docs.

    chipx86chipx86

    Let's flesh this out so it's clear what the purpose and responsibilities are.

    chipx86chipx86

    Let's have a _name suffix, to distingush it from a class or something.

    chipx86chipx86

    Missing Args.

    chipx86chipx86

    This is kind of vague. I'm not really left with an idea of what goes here. It'd be nice to …

    chipx86chipx86

    Missing *args.

    chipx86chipx86

    Missing a file docstring.

    chipx86chipx86

    "Elasticsearch". (I sure wish the "s" was still capitalized in their name...)

    chipx86chipx86

    Maybe say "... that the elasticsearch module ..."

    chipx86chipx86

    Would be nice to point to the docs. I have this in the Conditions stuff: This works as a :py:ref:`registry …

    chipx86chipx86

    "... with the specified ID."

    chipx86chipx86

    They don't return None if not found. They raise an exception. If we want to return None, we should make …

    chipx86chipx86

    Missing a file docstring.

    chipx86chipx86

    Would be nice to narrow down this selector by ID, if we can. (Not sure if the form has one.)

    chipx86chipx86

    Blank line between these.

    chipx86chipx86

    {% endblock scripts-post %}

    chipx86chipx86

    search before signals.

    chipx86chipx86

    This lost its docstring.

    chipx86chipx86

    No need for the parens and explicit tuple here.

    chipx86chipx86

    Missing Returns:

    chipx86chipx86

    Missing a file docstring.

    chipx86chipx86

    Missing a docstring.

    chipx86chipx86

    No need for the type=

    chipx86chipx86

    'SearchSettingsForm' imported but unused

    reviewbotreviewbot

    Col: 80 E501 line too long (113 > 79 characters)

    reviewbotreviewbot

    'elasticsearch' imported but unused

    reviewbotreviewbot

    Should this string be marked for localization?

    daviddavid

    Col: 80 E501 line too long (113 > 79 characters)

    reviewbotreviewbot

    'elasticsearch' imported but unused

    reviewbotreviewbot
    brennie
    david
    1. 
        
    2. Show all issues

      noqa?

      1. noqa is a pyflakes / pycodestyle indicator that this line should not be subject to linting. It prevent Review Bot from complaining about the unused import, as we're just importing it to see that it is installed.

    3. Show all issues

      Returns?

    4. 
        
    QH
    1. 
        
    2. 
        
    QH
    1. 
        
    2. 
        
    QH
    1. 
        
    2. reviewboard/admin/forms.py (Diff revision 1)
       
       
      Show all issues

      dddd

      1. Hey qhr,

        This is a production Review Board instance. Please don't create test reviews or comments here. I encourage you to use the demo instance instead.

    3. 
        
    brennie
    chipx86
    1. Foundation for all this looks great! Nearly all my comments have to do with documentation (I really want us to flesh these out going forward, so we can help foster a better development community and also make life easier for students.)

    2. Show all issues

      Can you make this field longer?

    3. Show all issues

      Can you make this field longer?

    4. reviewboard/admin/forms.py (Diff revision 2)
       
       
      Show all issues

      Missing a period.

      At first I was going to say this should say "Form," but it's managing multiple forms. Can you expand the comment and describe what this class is handling?

    5. reviewboard/admin/forms.py (Diff revision 2)
       
       
       
      Show all issues

      I think maybe, "If enabled, a search field will be provided for ..."

      1. These were all copy pasted :)

      2. Yeah. Many of these are very, very old. But while we're doing a redesign... :)

    6. reviewboard/admin/forms.py (Diff revision 2)
       
       
      Show all issues

      "review requests, diffs, and users."

    7. reviewboard/admin/forms.py (Diff revision 2)
       
       
      Show all issues

      This is redundant. We can get rid of it.

    8. reviewboard/admin/forms.py (Diff revision 2)
       
       
      Show all issues

      This is redundant. We can get rid of it.

    9. reviewboard/admin/forms.py (Diff revision 2)
       
       
      Show all issues

      Missing a description.

    10. reviewboard/admin/forms.py (Diff revision 2)
       
       
       
       
       
      Show all issues

      "... for the base form and every search engine settings form."""

      Which I'm not sure we want, actually. Probably just want it for the base form. I think we should take the specific arguments we need (data, files) and pass those below.

    11. reviewboard/admin/forms.py (Diff revision 2)
       
       
       
      Show all issues

      This is missing a "Returns".

    12. reviewboard/admin/forms.py (Diff revision 2)
       
       
      Show all issues

      Let's expand on the error message to make it more helpful:

      The search engine "%s" could not be found. If this was provided by an extension, you'll need to make sure the extension is enabled.
      
    13. reviewboard/admin/forms.py (Diff revision 2)
       
       
       
      Show all issues

      Missing a "Returns".

    14. reviewboard/admin/forms.py (Diff revision 2)
       
       
      Show all issues

      Missing docs.

    15. reviewboard/admin/forms.py (Diff revision 2)
       
       
      Show all issues

      Let's add the same comment here that we have on other forms:

      # Reload any important changes into the Django settings.
      
    16. reviewboard/admin/siteconfig.py (Diff revision 2)
       
       
       
      Show all issues

      We're going to need to migrate this setting.

      1. It already is. Take a look at SearchBackend.configuration.

    17. reviewboard/admin/siteconfig.py (Diff revision 2)
       
       
      Show all issues

      Same error as above.

    18. reviewboard/admin/views.py (Diff revision 2)
       
       
      Show all issues

      Missing docs.

    19. reviewboard/admin/views.py (Diff revision 2)
       
       
      Show all issues

      Let's pass in files as well, in case we have some backend in the future that requires some uploaded license key or something.

    20. reviewboard/search/__init__.py (Diff revision 2)
       
       
      Show all issues

      We should have a docstring at the top of this file.

    21. Show all issues

      We should have a docstring for this file.

    22. Show all issues

      Missing docs.

    23. Show all issues

      Let's flesh this out so it's clear what the purpose and responsibilities are.

    24. Show all issues

      Let's have a _name suffix, to distingush it from a class or something.

    25. reviewboard/search/search_backends/base.py (Diff revision 2)
       
       
       
      Show all issues

      Missing Args.

    26. reviewboard/search/search_backends/base.py (Diff revision 2)
       
       
       
       
      Show all issues

      This is kind of vague. I'm not really left with an idea of what goes here. It'd be nice to flesh this out a bit, maybe talk about the kinds of things this might want to check.

    27. reviewboard/search/search_backends/base.py (Diff revision 2)
       
       
       
       
       
       
       
      Show all issues

      Missing *args.

    28. Show all issues

      Missing a file docstring.

    29. Show all issues

      "Elasticsearch".

      (I sure wish the "s" was still capitalized in their name...)

    30. Show all issues

      Maybe say "... that the elasticsearch module ..."

    31. reviewboard/search/search_backends/registry.py (Diff revision 2)
       
       
       
       
       
      Show all issues

      Would be nice to point to the docs. I have this in the Conditions stuff:

      This works as a :py:ref:`registry <registry-guides>`, allowing additional
      choices to be added dynamically by extensions or other code.
      
    32. Show all issues

      "... with the specified ID."

    33. reviewboard/search/search_backends/registry.py (Diff revision 2)
       
       
       
       
       
       
      Show all issues

      They don't return None if not found. They raise an exception. If we want to return None, we should make sure it's doing that here.

      1. No they don't.

        This inherits from ExceptionFreeGetterMixin.

    34. Show all issues

      Missing a file docstring.

    35. Show all issues

      Would be nice to narrow down this selector by ID, if we can. (Not sure if the form has one.)

    36. Show all issues

      Blank line between these.

    37. Show all issues

      {% endblock scripts-post %}

    38. 
        
    brennie
    chipx86
    1. Just a few minor things left. I'm happy with this otherwise.

    2. reviewboard/admin/siteconfig.py (Diff revision 3)
       
       
       
       
      Show all issues

      search before signals.

    3. reviewboard/admin/siteconfig.py (Diff revision 3)
       
       
      Show all issues

      This lost its docstring.

    4. reviewboard/admin/siteconfig.py (Diff revision 3)
       
       
      Show all issues

      No need for the parens and explicit tuple here.

    5. reviewboard/search/search_backends/base.py (Diff revision 3)
       
       
       
       
       
       
       
       
       
       
       
       
       
      Show all issues

      Missing Returns:

    6. Show all issues

      Missing a file docstring.

    7. Show all issues

      Missing a docstring.

    8. Show all issues

      No need for the type=

    9. 
        
    brennie
    reviewbot
    1. Tool: Pyflakes
      Processed Files:
          reviewboard/admin/siteconfig.py
          reviewboard/admin/forms.py
          reviewboard/admin/views.py
          reviewboard/search/search_backends/registry.py
          reviewboard/search/search_backends/whoosh.py
          reviewboard/search/__init__.py
          reviewboard/search/search_backends/base.py
          reviewboard/search/search_backends/elasticsearch.py
      
      Ignored Files:
          reviewboard/htdocs/media/10854188_291516057725053_7460375966763285299_o.jpg
          reviewboard/templates/admin/search_settings.html
          reviewboard/htdocs/media/1420843716467.png
      
      
      
      Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/admin/siteconfig.py
          reviewboard/admin/forms.py
          reviewboard/admin/views.py
          reviewboard/search/search_backends/registry.py
          reviewboard/search/search_backends/whoosh.py
          reviewboard/search/__init__.py
          reviewboard/search/search_backends/base.py
          reviewboard/search/search_backends/elasticsearch.py
      
      Ignored Files:
          reviewboard/htdocs/media/10854188_291516057725053_7460375966763285299_o.jpg
          reviewboard/templates/admin/search_settings.html
          reviewboard/htdocs/media/1420843716467.png
      
      
    2. reviewboard/admin/views.py (Diff revision 4)
       
       
      Show all issues
       'SearchSettingsForm' imported but unused
      
    3. Show all issues
      Col: 80
       E501 line too long (113 > 79 characters)
      
    4. Show all issues
       'elasticsearch' imported but unused
      
    5. 
        
    brennie
    reviewbot
    1. Tool: Pyflakes
      Processed Files:
          reviewboard/admin/siteconfig.py
          reviewboard/admin/forms.py
          reviewboard/admin/views.py
          reviewboard/search/search_backends/registry.py
          reviewboard/search/search_backends/whoosh.py
          reviewboard/search/__init__.py
          reviewboard/search/search_backends/base.py
          reviewboard/search/search_backends/elasticsearch.py
      
      Ignored Files:
          reviewboard/htdocs/media/10854188_291516057725053_7460375966763285299_o.jpg
          reviewboard/templates/admin/search_settings.html
          reviewboard/htdocs/media/1420843716467.png
      
      
      
      Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/admin/siteconfig.py
          reviewboard/admin/forms.py
          reviewboard/admin/views.py
          reviewboard/search/search_backends/registry.py
          reviewboard/search/search_backends/whoosh.py
          reviewboard/search/__init__.py
          reviewboard/search/search_backends/base.py
          reviewboard/search/search_backends/elasticsearch.py
      
      Ignored Files:
          reviewboard/htdocs/media/10854188_291516057725053_7460375966763285299_o.jpg
          reviewboard/templates/admin/search_settings.html
          reviewboard/htdocs/media/1420843716467.png
      
      
    2. Show all issues
      Col: 80
       E501 line too long (113 > 79 characters)
      
    3. Show all issues
       'elasticsearch' imported but unused
      
    4. 
        
    david
    1. 
        
    2. reviewboard/admin/siteconfig.py (Diff revision 5)
       
       
       
       
      Show all issues

      Should this string be marked for localization?

    3. 
        
    brennie
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.0.x (34db670)