-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Hide _out
tables and restore metadata in Datasette
#3226
Conversation
This commit also resolves a couple of bugs in our metadata management and datasette deployment. Pretty much all out_ tables were missing metadata on datasette because DatasetteMetadata.from_data_source_ids() does some filtering that didn't include the output tables. Also, the epacamd_eia Source was incorrectly renamed to core_epa__assn_eia_epacamd during the big rename.
@@ -299,7 +299,7 @@ | |||
"license_raw": LICENSES["us-govt"], | |||
"license_pudl": LICENSES["cc-by-4.0"], | |||
}, | |||
"core_epa__assn_eia_epacamd": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an oopsie from #2995
src/pudl/metadata/classes.py
Outdated
for res in pkg.resources | ||
if res.etl_group in data_source_ids + extra_etl_groups | ||
] | ||
resources = Package.from_resource_ids().get_sorted_resources() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The resources are correctly sorted in the metadata.yml file but it doesn't have an effect on the final ordering in the datasette UI. Any idea how to do this @zaneselvans?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I might need to adjust the HTML templates datasette uses. I think it's currently just pulling the table names from the database directly: https://github.com/simonw/datasette/blob/2ff4d4a60a348c143f79d63c48c329ffd0c1f02f/datasette/templates/database.html#L50-L82
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The layout of Datasette pages (and the set of pages which exist) can be customized extensively with custom JavaScript, CSS, and Jinja templates
It seems like maybe we want a child-template that extends the database page that lists all of the tables, and sorts / filters them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if we want to hide all of the _out
tables, then it seems like we can add them to the list of hidden_tables
in the metadata that we generate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we need to create a directory of our own templates
and create a database-pudl.html
Jinja template that overrides the default database.html
template, at least for the content block?
…tasette, remove resource sorting
_out
tables and restore metadata in Datasette
…in database have datasette metadata
# Make sure we have the expected metadata for databases | ||
# headed to deployment. | ||
if deploy != "metadata": | ||
check_tables_have_metadata(metadata_yml, databases) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this solves the entanglement issue you mentioned @zaneselvans . We only check if all of the databases tables have datasette metadata if we are actually deploying datatsette.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the Datasette metadata is generated, and the checks rely on bespoke logic for constructing paths to the databases we expect to have metadata, and the dependence on the XBRL datapackage.json sometimes and the SQLite files other times and the PUDL Package other times all feels pretty fragile and janky, but that's beyond the scope of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added suggestions for a docstring and a more restrictive table name regex for sorting.
# Make sure we have the expected metadata for databases | ||
# headed to deployment. | ||
if deploy != "metadata": | ||
check_tables_have_metadata(metadata_yml, databases) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the Datasette metadata is generated, and the checks rely on bespoke logic for constructing paths to the databases we expect to have metadata, and the dependence on the XBRL datapackage.json sometimes and the SQLite files other times and the PUDL Package other times all feels pretty fragile and janky, but that's beyond the scope of this PR.
…ive regex for resource sorting
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3226 +/- ##
==========================================
+ Coverage 92.72% 92.83% +0.12%
==========================================
Files 145 145
Lines 13111 13156 +45
==========================================
+ Hits 12156 12213 +57
+ Misses 955 943 -12 ☔ View full report in Codecov by Sentry. |
Overview
This PR:
_out
tables from datasetteThis PR will not deal with sorting the tables on datasette.
Testing
How did you make sure this worked? How can a reviewer verify this?
To-do list