-
-
Notifications
You must be signed in to change notification settings - Fork 690
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
Proposal: Combine settings, metadata, static, etc. into a single datasette.yaml
File
#2093
Comments
I'm strongly in favour of combining settings, configuration and plugin configuration. I'm not keen on mixing in metadata as well - that feels like a different concept to me, and I'm unhappy with how that's already had things like plugin settings leak into it. I'm not yet sold on TOML - I actually find it less intuitive than YAML, surprisingly. They all have their warts I guess. Datasette already has the ability to consume JSON or YAML for metadata - maybe it could grow TOML support too? That way users could have a In terms of metadata: since that's means to be driven by a plugin hook anyway, maybe one of the potential sources of metadata is a |
I do like also being able to set options using command line options though - for things like SQL time limits I'd much rather be able to throw on So I'd want to support both. Which maybe means also having a way to set plugin options with CLI options.
|
I agree with not liking Though since plugin configuration currently lives in And ya, supporting both |
Maybe we can have a separate issue for revamping |
I agree, settings in the DB doesn't make sense but metadata does. On the JSON v YAML v TOML issue I just spotted Caddy has a concept of config adapters which they use to resolve exactly that problem: https://caddyserver.com/docs/config-adapters |
I'm not keen on requiring metadata to be within the database. I commonly have multiple DBs, from various sources, and having one config file to provide the metadata works out very well. I use Datasette with databases where I'm not the original source, needing to mutate them to add a metadata table or sqlite-docs makes me uncomfortable. |
Storing metadata in the database won't be required. I imagine there'll be many different ways to store metadata, including any possible The next question will be how precedence should work - i'd imagine metadata.json > plugins > datasette_metadata > sqlite-docs |
OK Here's the gameplan for this, which is closely tied to #2143 :
The format of Here's the current implementation plan:
|
datasette.toml
Filedatasette.yaml
File
* Checkpoint, moving top-level plugin config to datasette.json * Support database-level and table-level plugin configuration in datasette.yaml Refs #2093
Very often I get tripped up when trying to configure my Datasette instances. For example: if I want to change the port my app listen too, do I do that with a CLI flag, a
--setting
flag, insidemetadata.json
, or an env var? If I want to up the time limit of SQL statements, is that undermetadata.json
or a setting? Where does my plugin configuration go?Normally I need to look it up in Datasette docs, and I quickly find my answer, but the number of places where "config" goes it overwhelming.
--port
,--host
,--cors
, etc.--setting
, likedefault_page_size
,sql_time_limit_ms
etcmetadata.json
, including plugin configurationTypically my Datasette deploys are extremely long shell commands, with multiple
--setting
and other CLI flags.Proposal: Consolidate all "config" into
datasette.toml
I propose that we add a new
datasette.toml
that combines "settings", "metadata", and other common CLI flags like--port
and--cors
into a single file. It would be similar to "Cargo.toml" in Rust projects, "package.json" in Node projects, and "pyproject.toml" in Python, etc.A sample of what it could look like:
Pros
datasette.toml
instead of needing to learn metadata + settings + CLI flagsdatasette -c datasette-dev.toml
for local dev environments (enables SQL, debug plugins, long timeouts, etc.), and adatasette -c datasette-prod.toml
for "production" (lower timeouts, less plugins, monitoring plugins, etc.)Cons
datasette.toml
. However with enough documentation + announcements + examples, I think we can get ahead of it.--setting default_allow_sql off
override the value inside[settings]
? What about--port
?Other Notes
Toml
I chose toml over json because toml supports comments. I chose toml over yaml because Python 3.11 has builtin support for it. I also find toml easier to work with since it doesn't have the odd "gotchas" that YAML has ("ex
3.10
resolving to3.1
, NorwayNO
resolving tofalse
, etc.). It also mimicspyproject.toml
which is nice. Happy to change my mind about this howeverPlugin config will be difficult
Plugin config is currently in
metadata.json
in two places:"plugins.[plugin-name]"
. This fits well intodatasette.toml
as[plugins.plugin-name]
"databases.[db-name].tables.[table-name].plugins.[plugin-name]
. This doesn't fit that well intodatasette.toml
, unless it's nested under[metadata]
?Extensions, static, one-off plugins?
We could also include equivalents of
--plugins-dir
,--static
, and--load-extension
intodatasette.toml
, but I'd imagine there's a few security concerns there to think through.Explicitly list with plugins to use?
I believe Datasette by default will load all install plugins on startup, but maybe
datasette.toml
can specify a list of plugins to use? For example, a dev version ofdatasette.toml
can specifydatasette-pretty-traces
, but the prod version can leave it outThe text was updated successfully, but these errors were encountered: