{"html_url": "https://github.com/simonw/datasette/pull/2142#issuecomment-1683950031", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2142", "id": 1683950031, "node_id": "IC_kwDOBm6k_c5kXwnP", "user": {"value": 49699333, "label": "dependabot[bot]"}, "created_at": "2023-08-18T13:49:24Z", "updated_at": "2023-08-18T13:49:24Z", "author_association": "CONTRIBUTOR", "body": "Looks like these dependencies are updatable in another way, so this is no longer needed.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1854970601, "label": "Bump the python-packages group with 2 updates"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2143#issuecomment-1683420879", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2143", "id": 1683420879, "node_id": "IC_kwDOBm6k_c5kVvbP", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-08-18T06:33:24Z", "updated_at": "2023-08-18T15:15:34Z", "author_association": "OWNER", "body": "I completely agree: metadata is a mess, and it deserves our attention.\r\n\r\n> 1. Metadata cannot be updated without re-starting the entire Datasette instance.\r\n\r\nThat's not completely true - there are hacks around that. I have a plugin that applies one set of gnarly hacks for that here: https://github.com/simonw/datasette-remote-metadata - it's pretty grim though!\r\n\r\n> 2. The `metadata.json`/`metadata.yaml` has become a kitchen sink of unrelated (imo) features like plugin config, authentication config, canned queries\r\n\r\n100% this: it's a complete mess.\r\n\r\nDatasette used to have a `datasette --config foo:bar` mechanism, which I deprecated in favour of `datasette --setting foo bar` partly because I wanted to free up `--config` for pointing at a real config file, so we could stop dropping everything in `--metadata metadata.yml`.\r\n\r\n> 3. The Python APIs for defining extra metadata are a bit awkward (the `datasette.metadata()` class, `get_metadata()` hook, etc.)\r\n\r\nYes, they're not pretty at all.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1855885427, "label": "De-tangling Metadata before Datasette 1.0"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2143#issuecomment-1683429959", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2143", "id": 1683429959, "node_id": "IC_kwDOBm6k_c5kVxpH", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-08-18T06:43:33Z", "updated_at": "2023-08-18T15:19:07Z", "author_association": "OWNER", "body": "The single biggest design challenge I've had with metadata relates to how it should or should not be inherited.\r\n\r\nIf you apply a license to a Datasette instance, it feels like that should flow down to cover all of the databases and all of the tables within those databases.\r\n\r\nIf the license is at the database level, it should cover all tables.\r\n\r\nBut... should source do the same thing? I made it behave the same way as license, but it's presumably common for one database to have a single license but multiple different sources of data.\r\n\r\nThen there's title - should that inherit? It feels like title should apply to only one level - you may want a title that applies to the instance, then a different custom title for databases and tables.\r\n\r\nHere's the current state of play for metadata: https://docs.datasette.io/en/1.0a3/metadata.html\r\n\r\nSo there's `title` and `description` - and I'll be honest, I'm not 100% sure even I understand how those should be inherited down by tables/etc.\r\n\r\nThere's `description_html` which over-rides the `description` if it is set. It's a useful customization hack, but a bit surprising.\r\n\r\nThen there are these six:\r\n\r\n- `license`\r\n- `license_url`\r\n- `source`\r\n- `source_url`\r\n- `about`\r\n- `about_url`\r\n\r\nI added `about` later than the others, because I realized that plenty of my own projects needed a link to an article explaining them somewhere - e.g. https://scotrail.datasette.io/\r\n\r\nTables can also have column descriptions - just a string for each column. There's a demo of those here: https://latest.datasette.io/fixtures/roadside_attractions\r\n\r\nAnd then there's all of the other stuff, most of which feels much more like \"settings\" than \"metadata\":\r\n\r\n- `sort: created` - the custom sort order\r\n- `size: 10` for a custom page size for a specific table\r\n- `sortable_columns` to set which columns can be used to sort\r\n- `hidden: true` to hide a table\r\n- `label_column: title` is an interesting one - it lets you hint to Datasette which column should be displayed when there is a foreign key relationship. It's sort-of-metadata and sort-of-a-setting.\r\n- `facets` sets default facets, see https://docs.datasette.io/en/1.0a3/facets.html#facets-in-metadata\r\n- `facet_size` sets the number of facets to display\r\n- `fts_table` and `fts_pk` can be used to configure FTS, especially for views: https://docs.datasette.io/en/1.0a3/full_text_search.html\r\n\r\nAnd the authentication stuff! `allow` and `allow_sql` blocks: https://docs.datasette.io/en/1.0a3/authentication.html#defining-permissions-with-allow-blocks\r\n\r\nAnd the new `permissions` key in the 1.0 alphas: https://docs.datasette.io/en/1.0a3/authentication.html#other-permissions-in-metadata\r\n\r\nI think that might be everything (excluding the `plugins` settings stuff, which is also a bad fit for metadata.)\r\n\r\nAnd to make things even more confusing... I believe you can add arbitrary key/value pairs to your metadata and then use them in your templates! I think I've heard from at least one person who uses that ability.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1855885427, "label": "De-tangling Metadata before Datasette 1.0"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2143#issuecomment-1683435579", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2143", "id": 1683435579, "node_id": "IC_kwDOBm6k_c5kVzA7", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-08-18T06:49:39Z", "updated_at": "2023-08-18T06:49:39Z", "author_association": "OWNER", "body": "My ideal situation then would be something like this:\r\n\r\n- Metadata itself is VERY clearly described, including sensible rules for metadata inheritance where it makes sense. There is a `datasette.X` method for accessing it which is much more intuitive than `datasette.metadata()`.\r\n- It's possible that method should be an `async` method, because that would support things like plugins that lookup metadata in database tables better.\r\n- All templates etc switch to the new, clean, intuitive metadata mechanism before 1.0.\r\n- I'm interested in the option of metadata being able to live in a `_datasette_metadata` table in the databases themselves - either as a plugin or as a core feature. I think it makes a lot of sense for metadata to optionally live with the data that it describes.\r\n- Configuration gets split from metadata. The stuff that configures Datasette no longer lives in the `metadata.yml` file - it lives in `config.yml` (or even `datasette.yml`).\r\n\r\nCurrently we have three types of things:\r\n\r\n- Metadata - information about the data\r\n- Configuration - stuff like \"these columns should be sortable\" and \"this is configured as `fts_table`\" and suchlike\r\n- Settings - the stuff that you pass to `datasette --setting x y` on server start.\r\n\r\nShould settings and configuration be separate? I'm not 100% sure that they should - maybe those two concepts should be combined somehow.\r\n\r\nConfiguration directory mode needs to be considered too: https://docs.datasette.io/en/stable/settings.html#configuration-directory-mode - interestingly it already has a thing where it can pick up settings from a `settings.json` file - where settings are things like `datasette --setting sql_time_limit_ms 4000`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1855885427, "label": "De-tangling Metadata before Datasette 1.0"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2143#issuecomment-1683440597", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2143", "id": 1683440597, "node_id": "IC_kwDOBm6k_c5kV0PV", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-08-18T06:54:49Z", "updated_at": "2023-08-18T06:54:49Z", "author_association": "OWNER", "body": "A related point that I've been considering a lot recently: it turns out that sometimes I really want to define settings on the CLI instead of in a file, purely for convenience.\r\n\r\nIt's pretty annoying when I want to try out a new plugin but I have to create a dedicated `metadata.yml` file for it just to setup a single option - I'd love to have the option to be able to run this instead:\r\n\r\n```bash\r\ndatasette data.db --plugin-setting datasette-upload-csvs default-database data\r\n```\r\n\r\nSo maybe there's a world in which all of the settings can be applied in a `datasette.yml` file OR with command-line options.\r\n\r\nThat gets trickier when you need to pass a nested structure or similar, but we could always support those as JSON:\r\n\r\n```bash\r\ndatasette data.db --plugin-setting datasette-emoji-reactions emoji '[\"\ud83d\ude3c\", \"\ud83d\udc3a\"]'\r\n```\r\nNote that we kind of have precedent for this in `datasette publish`: https://docs.datasette.io/en/stable/publish.html#custom-metadata-and-plugins\r\n\r\n```bash\r\ndatasette publish heroku my_database.db \\\r\n --name my-heroku-app-demo \\\r\n --install=datasette-auth-github \\\r\n --plugin-secret datasette-auth-github client_id your_client_id \\\r\n --plugin-secret datasette-auth-github client_secret your_client_secret\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1855885427, "label": "De-tangling Metadata before Datasette 1.0"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2143#issuecomment-1683443891", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2143", "id": 1683443891, "node_id": "IC_kwDOBm6k_c5kV1Cz", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-08-18T06:58:15Z", "updated_at": "2023-08-18T06:58:15Z", "author_association": "OWNER", "body": "Hah, that `--plugin-secret` thing was a messy solution I came up with to the problem that all metadata is visible at `/-/metadata` - so if you need to stash a secret you need a way to keep it not-visible in there!\r\n\r\nHence the whole `$env` mess: https://docs.datasette.io/en/stable/plugins.html#secret-configuration-values\r\n\r\n```json\r\n{\r\n \"plugins\": {\r\n \"datasette-auth-github\": {\r\n \"client_secret\": {\r\n \"$env\": \"GITHUB_CLIENT_SECRET\"\r\n }\r\n }\r\n }\r\n}\r\n```\r\n\r\nIf configuration and metadata were separate we could ditch that whole messy situation - configuration can stay hidden, metadata can stay public.\r\n\r\nThough I have been thinking that Datasette might benefit from a \"secrets\" mechanism that's separate from configuration and metadata... kind of like what LLM has: https://llm.datasette.io/en/stable/help.html#llm-keys-help", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1855885427, "label": "De-tangling Metadata before Datasette 1.0"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2143#issuecomment-1684202932", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2143", "id": 1684202932, "node_id": "IC_kwDOBm6k_c5kYuW0", "user": {"value": 15178711, "label": "asg017"}, "created_at": "2023-08-18T17:10:21Z", "updated_at": "2023-08-18T17:10:21Z", "author_association": "CONTRIBUTOR", "body": "I agree with all your points!\r\n\r\nI think the best solution would be having a `datasette.json` config file, where you \"configure\" your datasette instances, with settings, permissions/auth, plugin configuration, and table settings (sortable column, label columns, etc.). Which #2093 would do.\r\n\r\nThen optionally, you have a `metadata.json`, or use `datasette_metadata`, or some other plugin to define metadata (ex the future [sqlite-docs](https://github.com/asg017/sqlite-docs) plugin).\r\n\r\nEverything in `datasette.json` could also be overwritten by CLI flags, like `--setting key value`, `--plugin xxxx key value`.\r\n\r\nWe could even completely remove `settings.json` in favor or just `datasette.json`. Mostly because I think the less files the better, especially if they have generic names like `settings.json` or `config.json`. ", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1855885427, "label": "De-tangling Metadata before Datasette 1.0"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2143#issuecomment-1684205563", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2143", "id": 1684205563, "node_id": "IC_kwDOBm6k_c5kYu_7", "user": {"value": 15178711, "label": "asg017"}, "created_at": "2023-08-18T17:12:54Z", "updated_at": "2023-08-18T17:12:54Z", "author_association": "CONTRIBUTOR", "body": "Another option would be, instead of flat `datasette.json`/`datasette.yaml` files, we could instead use a Python file, like `datasette_config.py`. That way one could dynamically generate config (ex dev vs prod, auto-discover credentials, etc.). Kinda like Django settings.\r\n\r\nThough I imagine Python imports might make this complex to do, and json/yaml is already supported and pretty easy to write\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1855885427, "label": "De-tangling Metadata before Datasette 1.0"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2143#issuecomment-1684484426", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2143", "id": 1684484426, "node_id": "IC_kwDOBm6k_c5kZzFK", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-08-18T22:12:52Z", "updated_at": "2023-08-18T22:12:52Z", "author_association": "OWNER", "body": "Yeah, I'm convinced by that. There's not point in having both `settings.json` and `datasette.json`.\r\n\r\nI like `datasette.json` ( / `datasette.yml`) as a name. That can be the file that lives in your config directory too, so if you run `datasette .` in a folder containing `datasette.yml` all of those settings get picked up.\r\n\r\nHere's a thought for how it could look - I'll go with the YAML format because I expect that to be the default most people use, just because it supports multi-line strings better.\r\n\r\nI based this on the big example at https://docs.datasette.io/en/1.0a3/metadata.html#using-yaml-for-metadata - and combined some bits from https://docs.datasette.io/en/1.0a3/authentication.html as well.\r\n\r\n```yaml\r\ntitle: Demonstrating Metadata from YAML\r\ndescription_html: |-\r\n
This description includes a long HTML string
\r\nThis demonstrates basic LIKE search\r\n\r\npermissions:\r\n debug-menu:\r\n id: '*'\r\n\r\nplugins:\r\n datasette-ripgrep:\r\n path: /usr/local/lib/python3.11/site-packages\r\n```\r\nI'm inclined to say we try to be a super-set of the existing `metadata.yml` format, at least where it makes sense to do so. That way the upgrade path is smooth for people. Also, I don't think the format itself is terrible - it's the name that's the big problem.\r\n\r\nIn this example I've mixed in one extra concept: that `settings:` block with a bunch of settings in it.\r\n\r\nThere are some things in there that look a little bit like metadata - the `title` and `description_html` fields.\r\n\r\nBut _are they_ metadata? The title and description of the overall instance feels like it could be described as general configuration. The stuff for the `query` should live where the query itself is defined.\r\n\r\nNote that queries can be defined by a plugin hook too: https://docs.datasette.io/en/1.0a3/plugin_hooks.html#canned-queries-datasette-database-actor\r\n\r\nWhat do you think? Is this the right direction, or are you thinking there's a more radical redesign that would make sense here?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1855885427, "label": "De-tangling Metadata before Datasette 1.0"}, "performed_via_github_app": null}
{"html_url": "https://github.com/simonw/datasette/issues/2143#issuecomment-1684485591", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2143", "id": 1684485591, "node_id": "IC_kwDOBm6k_c5kZzXX", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-08-18T22:14:35Z", "updated_at": "2023-08-18T22:14:35Z", "author_association": "OWNER", "body": "Actually there is one thing that I'm not comfortable about with respect to the existing design: the way the database / tables stuff is nested.\r\n\r\nThey assume that the user will attach the database to Datasette using a fixed name - `docs.db` or whatever.\r\n\r\nBut what if we want to support users downloading databases from each other and attaching them to Datasette where those DBs might carry some of their own configuration?\r\n\r\nMoving metadata into the databases makes sense there, but what about database-specific settings like the default sort order for a table, or configured canned queries?\r\n\r\nHaving those tied to the filename of the database itself feels unpleasant to me. But how else could we handle this?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1855885427, "label": "De-tangling Metadata before Datasette 1.0"}, "performed_via_github_app": null}
{"html_url": "https://github.com/simonw/datasette/issues/2143#issuecomment-1684488526", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2143", "id": 1684488526, "node_id": "IC_kwDOBm6k_c5kZ0FO", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-08-18T22:18:39Z", "updated_at": "2023-08-18T22:18:39Z", "author_association": "OWNER", "body": "> Another option would be, instead of flat `datasette.json`/`datasette.yaml` files, we could instead use a Python file, like `datasette_config.py`. That way one could dynamically generate config (ex dev vs prod, auto-discover credentials, etc.). Kinda like Django settings.\r\n\r\n> Another option would be, instead of flat `datasette.json`/`datasette.yaml` files, we could instead use a Python file, like `datasette_config.py`. That way one could dynamically generate config (ex dev vs prod, auto-discover credentials, etc.). Kinda like Django settings.\r\n\r\nI'm not a fan of that. I feel like software history is full of examples of projects that implemented configuration-as-code and then later regretted it - the most recent example is `setup.py` in Python turning into `pyproject.yaml`, but I feel like I've seen that pattern play out elsewhere too.\r\n\r\nI don't think having people dynamically generate JSON/YAML for their configuration is a big burden. I'd have to see some very compelling use-cases to convince me otherwise.\r\n\r\nThat said, I do really like a bias towards settings that can be changed at runtime. Datasette has suffered a bit from some settings that can't be easily changed at runtime already - hence my gnarly https://github.com/simonw/datasette-remote-metadata plugin.\r\n\r\nFor things like Datasette Cloud for example the more people can configure without rebooting their container the better!\r\n\r\nI don't think live reconfiguration at runtime is incompatible with JSON/YAML configuration though. Caddy is one of my favourite examples of software that can be entirely re-configured at runtime by POSTING a big blob of JSON to it: https://caddyserver.com/docs/quick-starts/api\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1855885427, "label": "De-tangling Metadata before Datasette 1.0"}, "performed_via_github_app": null}
{"html_url": "https://github.com/simonw/datasette/issues/2143#issuecomment-1684496274", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2143", "id": 1684496274, "node_id": "IC_kwDOBm6k_c5kZ1-S", "user": {"value": 15178711, "label": "asg017"}, "created_at": "2023-08-18T22:30:45Z", "updated_at": "2023-08-18T22:30:45Z", "author_association": "CONTRIBUTOR", "body": "> That said, I do really like a bias towards settings that can be changed at runtime\r\n\r\nDoes this include things like `--settings` values or plugin config? I can totally see being able to update metadata without restarting, but not sure if that would work well with `--setting`, plugin config, or auth/permissions stuff. \r\n\r\nWell it could work with `--setting` and auth/permissions, with a lot of core changes. But changing plugin config on the fly could be challenging, for plugin authors. ", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1855885427, "label": "De-tangling Metadata before Datasette 1.0"}, "performed_via_github_app": null}
{"html_url": "https://github.com/simonw/datasette/pull/2144#issuecomment-1683963463", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2144", "id": 1683963463, "node_id": "IC_kwDOBm6k_c5kXz5H", "user": {"value": 22429695, "label": "codecov[bot]"}, "created_at": "2023-08-18T13:58:39Z", "updated_at": "2023-08-18T13:58:39Z", "author_association": "NONE", "body": "## [Codecov](https://app.codecov.io/gh/simonw/datasette/pull/2144?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) Report\nPatch and project coverage have no change.\n> Comparison is base [(`943df09`)](https://app.codecov.io/gh/simonw/datasette/commit/943df09dcca93c3b9861b8c96277a01320db8662?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) 92.06% compared to head [(`3a97755`)](https://app.codecov.io/gh/simonw/datasette/pull/2144?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) 92.06%.\n\nAdditional details and impacted files
\n\n\n```diff\n@@ Coverage Diff @@\n## main #2144 +/- ##\n=======================================\n Coverage 92.06% 92.06% \n=======================================\n Files 40 40 \n Lines 5937 5937 \n=======================================\n Hits 5466 5466 \n Misses 471 471 \n```\n\n\n\n\n