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

  2. 
      
QH
  1. 
      
  2. 
      
QH
  1. 
      
  2. 
      
QH
  1. 
      
  2. reviewboard/admin/forms.py (Diff revision 1)
     
     
    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. Can you make this field longer?

  3. reviewboard/admin/forms.py (Diff revision 2)
     
     

    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?

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

    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... :)

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

    "review requests, diffs, and users."

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

    This is redundant. We can get rid of it.

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

    This is redundant. We can get rid of it.

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

    Missing a description.

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

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

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

    This is missing a "Returns".

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

    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.
    
  12. reviewboard/admin/forms.py (Diff revision 2)
     
     
     

    Missing a "Returns".

  13. reviewboard/admin/forms.py (Diff revision 2)
     
     

    Missing docs.

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

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

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

    We're going to need to migrate this setting.

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

  16. reviewboard/admin/siteconfig.py (Diff revision 2)
     
     

    Same error as above.

  17. reviewboard/admin/views.py (Diff revision 2)
     
     

    Missing docs.

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

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

  19. reviewboard/search/__init__.py (Diff revision 2)
     
     

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

  20. We should have a docstring for this file.

  21. Missing docs.

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

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

  24. reviewboard/search/search_backends/base.py (Diff revision 2)
     
     
     

    Missing Args.

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

    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.

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

    Missing *args.

  27. Missing a file docstring.

  28. "Elasticsearch".

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

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

  30. reviewboard/search/search_backends/registry.py (Diff revision 2)
     
     
     
     
     

    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.
    
  31. "... with the specified ID."

  32. reviewboard/search/search_backends/registry.py (Diff revision 2)
     
     
     
     
     
     

    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.

  33. Missing a file docstring.

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

  35. Blank line between these.

  36. {% endblock scripts-post %}

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

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

    search before signals.

  3. reviewboard/admin/siteconfig.py (Diff revision 3)
     
     

    This lost its docstring.

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

    No need for the parens and explicit tuple here.

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

    Missing Returns:

  6. Missing a file docstring.

  7. Missing a docstring.

  8. 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)
     
     
     'SearchSettingsForm' imported but unused
    
  3. Col: 80
     E501 line too long (113 > 79 characters)
    
  4.  '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. Col: 80
     E501 line too long (113 > 79 characters)
    
  3.  'elasticsearch' imported but unused
    
  4. 
      
david
  1. 
      
  2. reviewboard/admin/siteconfig.py (Diff revision 5)
     
     
     
     

    Should this string be marked for localization?

  3. 
      
brennie
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-3.0.x (34db670)
Loading...