Dynamic Configuration/Metadata - A proposed plugin hook & implementation #1322
Unanswered
brandonrobertz
asked this question in
General
Replies: 1 comment 1 reply
-
Having thought about this for a while I'd love to review a pull request of what you have so far. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There have been several issues related to the ability to change certain things inside Datasette without rebooting or re-deploying the app. NextLI is trying to open Datasette to non-technical users (people who aren't CLI comfortable) and that has required us to be able to do things like live-import new datasets and change metadata (also known as "configuration") on-the-fly. In response to this need, I've developed a fork of Datasette that adds a new plugin hook around configuration:
This plugs into
Datasette.metadata()
andDataette._metadata
where the rest of the application (plugins included) pulls configuration from. This plugin hook merges anything returned from plugins with any local configuration provided (e.g., via metadata.yml). In the current implementation, the on-disk configuration can't be overridden by plugins as a security feature.Plugin allows us to do the following:
_datasette_metadata
or something).Related issues this would solve (non-exhaustive list):
Open questions:
async or sync? The current implementation I've been testing is synchronous. This is the easiest path because is requires the smallest amount of code to change. Switching it to async would allow for more complex configuration strategies, but would force more code to have their function signatures change to async (since async infects all sync code). I've benchmarked the plugin hook with the datasette-live-config plugin and even with a non-optimized hook implementation that opens the DB connection every time, it adds <30ms.
What do we do with the non-defined areas of the metadata? I have JSON schema of
metadata.yaml
, butplugins
,allow
andallow_sql
are undefined. In the UI I have for editing config, I leave these parts as JSON text for manual editing.Simon has been talking about re-naming metadata and/or splitting metadata up. Should this plugin be named
get_configuration
to be future safe? Should the other things change before this plugin gets merged?Beta Was this translation helpful? Give feedback.
All reactions