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

feat(explorers): allow referencing indicators by catalog path #3748

Merged
merged 24 commits into from
Jul 2, 2024

Conversation

marcelgerber
Copy link
Member

@marcelgerber marcelgerber commented Jun 26, 2024

Fixes #3711.

So!

I worked on using ETL paths in indicator-based explorers for the last few days.
This means that something like this is now valid:
CleanShot 2024-07-02 at 14 25 40

How this works

The way this works is that, at baking time, we resolve all catalog paths contained in the graphers and columns sections of the explorer config.
The explorer config is then transformed in such a way that any catalog paths are replaced by their indicator IDs, and this transformed explorer config is then baked and shipped to the browser. That is, the browser never really needs to know about the existence of catalog paths.

The fields that are transformed are:

  • graphers:
    • yVariableIds
    • xVariableId
    • sizeVariableId
    • colorVariableId
  • columns
    • catalogPath -> variableId

As you can see above, most fields have not been renamed. That is, any of yVariableIds etc. can now contain either an integer variable ID or a string catalog path (or, in the case of yVariableIds, in theory also a mix of both).

Error handling

One caveat here is error handling, i.e. when an indicator can't be found for a catalog path.
In that case:

  • An error is sent to Bugsnag at bake time, mentioning the count and names of the corresponding catalog paths
  • The "baked explorer" still contains some catalog paths in fields like yIndicatorIds, xIndicatorId, etc., and just chooses to ignore them

This means: If any of the ETL paths are invalid, a Bugsnag error will be sent at bake time. The explorer will still get baked, but will be partially-broken.

PR tips

On an explorer page, you can get to the baked explorer config using explorer.explorerProgram.prettify() in the console. You can then copy this as plaintext (Chrome: "Copy string contents") and inspect it somewhere.


Todos

  • Do we also send Bugsnag errors when previewing?
  • Check that embedding these explorers works fine
  • Think about having a explorer-global catalogPathPrefix or so?
    • Easy to add later on, if we so desire :)
  • Currently, we don't do any error handling for unknown catalog paths in the columns.catalogPath section. Should we?
  • It's not great that we have string types for some columns now, which are pretty much only present before baking.
  • Check logic determining whether it's a variable-based or slug-based explorer (explorerProgram.chartCreationMode)
  • Oh god, editing in admin is broken because it's using localStorage
  • Button / or toggle to clear localStorage, or switch between localStorage and authored
  • Check that various existing explorers still work as intended
  • After merge: Update explorer mirroring automation https://github.com/owid/automation/blob/main/automation/mirror_explorers.py#L318

gridLang/GridLangConstants.ts Fixed Show fixed Hide fixed
gridLang/GridLangConstants.ts Fixed Show fixed Hide fixed
gridLang/GridLangConstants.ts Fixed Show fixed Hide fixed
@owidbot
Copy link
Contributor

owidbot commented Jun 26, 2024

Quick links (staging server):

Site Admin Wizard

Login: ssh owid@staging-site-explorer-by-etl-path

SVG tester:

Number of differences (default views): 94 (322819) ❌
Number of differences (all views): 250 (6f38b9) ❌

Edited: 2024-07-02 15:59:43 UTC
Execution time: 1.19 seconds

@marcelgerber marcelgerber force-pushed the explorer-by-etl-path branch from cc209f4 to cff7994 Compare July 2, 2024 09:32
@marcelgerber marcelgerber force-pushed the explorer-by-etl-path branch from 181a244 to 6e75b04 Compare July 2, 2024 09:35
@marcelgerber
Copy link
Member Author

For review purposes: https://github.com/owid/owid-content/tree/explorer-etl-path-review contains two catalog-path-powered explorers: population-and-demography and population-source.

The staging server for this branch also has a catalog-path-based population-and-demography, but using the 2024 data already because lucas is currently working on that.

@marcelgerber
Copy link
Member Author

I now added an admin-only checkbox that lets one easily switch between viewing the saved or changed explorer config (preview will only work properly using the saved version).

CleanShot.2024-07-02.at.16.20.08.mp4

@marcelgerber marcelgerber marked this pull request as ready for review July 2, 2024 15:22
Copy link
Contributor

@danyx23 danyx23 left a comment

Choose a reason for hiding this comment

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

Nice, this is a neat feature! Have you adapted the script in automation that imports explorers into the db? If not, can you create an issue and assign it to me?

@marcelgerber marcelgerber changed the title feat(explorers): allow referencing indicators by ETL path feat(explorers): allow referencing indicators by catalog path Jul 2, 2024
@marcelgerber marcelgerber merged commit a0b14b7 into master Jul 2, 2024
20 checks passed
@marcelgerber marcelgerber deleted the explorer-by-etl-path branch July 2, 2024 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In indicator-based explorers, allow referencing indicators by ETL path
3 participants