Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨(backends) granular data backends without template pattern #488

Merged
merged 2 commits into from
Nov 8, 2023

Conversation

SergioSim
Copy link
Collaborator

Purpose

Currently, not all backends follow the base interface strictly.
This is problematic as we need to know in advance what methods a backend supports for the CLI usage.

Also, we want to automatically discover backends in the data/backends sub-directories for CLI and LRS usage and handle import failures gracefully, to exclude backends with unmet dependencies.

Proposal

  • simplify the BaseDataBackend interface to allow backends to follow the base interface more strictly.

The write/list methods are extracted in separate interfaces (Writable, Listable).
Thus, by default, a backend only needs to support the status/read and close methods, and its functionality
can be extended by inheriting the Writable/Listable interfaces.

  • import backends dynamically

Instead of using BackendSettings to discover backends we implement a get_backends function to search for backends in the data/backends sub-directories.

@SergioSim SergioSim self-assigned this Oct 30, 2023
@SergioSim SergioSim force-pushed the granular-data-backends-without-template-pattern branch 4 times, most recently from ca8f722 to 7da89f0 Compare October 30, 2023 09:23
@wilbrdt wilbrdt added this to the 4.0 milestone Oct 30, 2023
Copy link
Contributor

@wilbrdt wilbrdt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alt text
Loving it, really nice work!
Not so much to say, just one remark on the runserver command

src/ralph/utils.py Outdated Show resolved Hide resolved
src/ralph/utils.py Outdated Show resolved Hide resolved
src/ralph/cli.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Leobouloc Leobouloc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read this up to the tests. I have just a few minor questions/comments for now.

src/ralph/api/routers/health.py Show resolved Hide resolved
src/ralph/backends/data/async_es.py Outdated Show resolved Hide resolved
src/ralph/backends/data/base.py Show resolved Hide resolved
src/ralph/backends/data/ldp.py Show resolved Hide resolved
@SergioSim SergioSim requested a review from jmaupetit November 2, 2023 13:23
@SergioSim SergioSim force-pushed the granular-data-backends-without-template-pattern branch 2 times, most recently from 7150453 to 4b073eb Compare November 6, 2023 09:27
Copy link
Contributor

@wilbrdt wilbrdt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alt text
Some nitpicking but otherwise looks good to me! 🎉

.env.dist Outdated Show resolved Hide resolved
.env.dist Outdated Show resolved Hide resolved
src/tray/vars/vault/main.yml.j2 Show resolved Hide resolved
@SergioSim SergioSim force-pushed the granular-data-backends-without-template-pattern branch 2 times, most recently from c37bf4b to 88d475a Compare November 8, 2023 08:18
We simplify the base data backend interface by moving out
the write and list methods.
Now, data backends that implement the list and write methods should
inherit from Writable and Listable classes.
We want to automatically discover backends in the data/backends
sub-directories for CLI and LRS usage.
We also now handle import failures gracefully, thus backends with
unmet dependencies are excluded.
@SergioSim SergioSim force-pushed the granular-data-backends-without-template-pattern branch from 88d475a to 1c66674 Compare November 8, 2023 13:33
@SergioSim SergioSim merged commit df26b97 into master Nov 8, 2023
@SergioSim SergioSim deleted the granular-data-backends-without-template-pattern branch November 8, 2023 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Fix import with optional backends dependencies Improve clarity of utils.py functions
4 participants