Currently, the _configure_mount has a long static list of if/elif with all the included backend, starting here:
|
def _configure_mount(self, config: dict[str, Any]) -> None: |
and most of them are based on FsspecBackend, which contains a long static list if/elif based on the type provided.
My 2¢:
- The approach makes it hard to add custom external backend providers
- It creates big generic backend with all the logic of all the plugins, which contains all the logic of all the backends, including the configuration validation
- Unit testing to big objects is not very fast and practical
Proposal:
- Split all the backends to specific classes (HttpBackend, GithubBackend etc) deriving from common ancestors, fsspec could be mixed in.
- The base classe provides a configuration validation method, which is then implemented internally by each derived backend class, raising StorageConfigError accordingly
- Implement an
add_backend(self, cls, configuration) public method to the manager, which will create the backend instance and invoke their validation method. If correct, add the instance to the available backends
- The configure() method can lookup the 'type' to use the correct class, maintaning compatibility with the current interface, by then invoking the above method.
- The type->cls mapping can be provided by the backends package constructor, with a one time loading from the package itself.
Currently, the _configure_mount has a long static list of if/elif with all the included backend, starting here:
genro-storage/genro_storage/manager.py
Line 326 in b90ece7
and most of them are based on FsspecBackend, which contains a long static list if/elif based on the type provided.
My 2¢:
Proposal:
add_backend(self, cls, configuration)public method to the manager, which will create the backend instance and invoke their validation method. If correct, add the instance to the available backends