Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Refactor strategy instantiation for more extensitiliby #1254

Merged
merged 12 commits into from
Sep 7, 2022

Commits on Sep 7, 2022

  1. Instantiate strategies via abstract Strategy base class

    A generalized Strategy abstract base class provides generalized getter methods
    that instantiate strategy subclasses (implementations).
    These methods rely on the builtin __subclasses__() method to identify Strategy subclasses,
    which allows for more dynamic and extensible strategy implementation, removing the need
    for a hardcoded enumeration of supported Strategy implementations.
    Abstract strategy types inherit from this new abstract base class,
    and strategy subclasses (implementations) must provide `name` and `configuration_model` attributes
    that are leveraged by new instantiation mechanism in the abstract base class.
    Adam Sachs authored and Adam Sachs committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    88aec8f View commit details
    Browse the repository at this point in the history
  2. Update get_description() to be a class rather than static method

    This allows the method to leverage the new `name` class variable rather than
    relying on a static constant variable.
    Adam Sachs authored and Adam Sachs committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    991a2e0 View commit details
    Browse the repository at this point in the history
  3. Remove strategy factories and update references

    Strategy factories are no longer needed with refactored Strategy getters.
    Update the uses (references) of strategy factories throughout the codebase
    to now rely on the new Strategy getters.
    Strategy subclasses (implementations) now need to be imported explicitly
    in __init__.py's because they used to be imported in factory modules.
    Also remove the old MaskingStrategy registration/factory mechanisms.
    Adam Sachs authored and Adam Sachs committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    6cf919a View commit details
    Browse the repository at this point in the history
  4. Remove strategy name constants

    Now that the abstract Strategy base class enforces implementation subclasses
    to have a `name` class attribute, this attribute should be relied upon rather than
    the arbitrary name constants declared previously.
    The get_strategy_name() abstract method is also superfluous, as the `name`
    class attribute can be used as a standardized way to retrieve the strategy name.
    Adam Sachs authored and Adam Sachs committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    a8ceb2d View commit details
    Browse the repository at this point in the history
  5. Remove get_configuration_model() abstract method

    The generalized strategy getter now relies upon the `configuration_model`
    class variable that's on each Strategy. Therefore we no longer need the
    get_configuration_model() getter on each Strategy subclass.
    Adam Sachs authored and Adam Sachs committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    7204d11 View commit details
    Browse the repository at this point in the history
  6. Update MaskingStrategy docs with new Strategy functionality

    Adam Sachs authored and Adam Sachs committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    244d67d View commit details
    Browse the repository at this point in the history
  7. Update changelog

    Adam Sachs authored and Adam Sachs committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    d3221ec View commit details
    Browse the repository at this point in the history
  8. Improve recursion in _find_all_strategy_subclasses

    Adam Sachs authored and Adam Sachs committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    44ece6b View commit details
    Browse the repository at this point in the history
  9. Fix recursion bug when finding all strategies

    Update associated tests to make sure the recursion is properly tested
    Adam Sachs authored and Adam Sachs committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    c8001aa View commit details
    Browse the repository at this point in the history
  10. Tweak conditional for falsy check

    Adam Sachs authored and Adam Sachs committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    6ed4701 View commit details
    Browse the repository at this point in the history
  11. Make get_strategies endpoint test more robust

    Adam Sachs authored and Adam Sachs committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    393814e View commit details
    Browse the repository at this point in the history
  12. Fix typo in documentation

    Adam Sachs authored and Adam Sachs committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    48ecfa0 View commit details
    Browse the repository at this point in the history