Skip to content

Backend architecture change proposal #49

@cgabriel

Description

@cgabriel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions