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

✨ improve grapher chart component #3663

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e765382
📊 fertility: twinning
lucasrodes Nov 26, 2024
8754c08
Merge branch 'master' into data-twinning
lucasrodes Nov 26, 2024
861091f
snapshot
lucasrodes Nov 26, 2024
774a4ac
re-organize DAG
lucasrodes Nov 26, 2024
2f7642d
add support for 7z
lucasrodes Nov 26, 2024
529e7bb
meadow
lucasrodes Nov 26, 2024
5a9dce7
wip
lucasrodes Nov 26, 2024
b7af634
Merge branch 'master' into data-twinning
lucasrodes Nov 26, 2024
f0f38cb
Merge branch 'master' into data-twinning
lucasrodes Nov 26, 2024
f206a9d
grapher
lucasrodes Nov 26, 2024
b8606a0
improve docs
lucasrodes Nov 26, 2024
15712cb
tweak annotation
lucasrodes Nov 26, 2024
5f14904
add multiple to ratio delivery ratio
lucasrodes Nov 26, 2024
730e1d2
bug
lucasrodes Nov 26, 2024
0a99512
Merge branch 'master' into data-twinning
lucasrodes Nov 26, 2024
165e88b
chore: py7zr
lucasrodes Nov 26, 2024
c670f00
rollback dependencies
lucasrodes Nov 26, 2024
0a70625
add dependency to datautils
lucasrodes Nov 26, 2024
4c7ce00
add note
lucasrodes Nov 26, 2024
6867a18
wip
lucasrodes Nov 26, 2024
9fce051
fix ci/cd
lucasrodes Nov 26, 2024
ffb3612
improve metadata readability
lucasrodes Nov 26, 2024
321d80d
ci/cd
lucasrodes Nov 26, 2024
65cc3d5
wip
lucasrodes Nov 26, 2024
1598b39
Merge branch 'master' into data-twinning
lucasrodes Nov 29, 2024
6d2330e
remove duplicated steps
lucasrodes Nov 29, 2024
7e6439c
✨ improve grapher chart component
lucasrodes Nov 29, 2024
c0fd51b
Merge branch 'data-twinning' into enhance-grapher-chart-improvement-0…
lucasrodes Nov 29, 2024
c214292
wip
lucasrodes Nov 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions apps/pr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def bake_branch_name(repo, pr_title, no_llm, remote_branches):
category = pr_title.category

# Get input title (without emoji, scope, etc.)
title = _extract_relevant_title_for_branch_name(pr_title.title, not no_llm)
title = _extract_relevant_title_for_branch_name(pr_title.title, category, not no_llm)

# Bake complete PR branch name
# name = f"{user}-{category}-{title}"
Expand All @@ -383,13 +383,14 @@ def bake_branch_name(repo, pr_title, no_llm, remote_branches):
# if name in remote_branches:
# log.info("Generating a hash for this branch name to prevent name collisions.")
# name = f"{name}-{user}"
if name in remote_branches:
local_branches = [branch.name for branch in repo.branches]
if (name in remote_branches) or (name in local_branches):
log.info("Generating a hash for this branch name to prevent name collisions.")
name = f"{name}-{generate_short_hash()}"
return name


def _extract_relevant_title_for_branch_name(text_in: str, use_llm) -> str:
def _extract_relevant_title_for_branch_name(text_in: str, category: str, use_llm) -> str:
"""
Process the input string by:
1. Removing all symbols, keeping only letters and numbers.
Expand All @@ -411,8 +412,13 @@ def _extract_relevant_title_for_branch_name(text_in: str, use_llm) -> str:

# Split into tokens/words
tokens = cleaned_text.split()

# Clean if there is word included in category
tokens = [t for t in tokens if t.lower() != category]

# Keep only the first 3 tokens
tokens = tokens[:3]

# Combine tokens with '-'
name = "-".join(tokens).lower()

Expand Down
70 changes: 17 additions & 53 deletions dag/demography.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
steps:
####################################
# Population #######################
####################################
########################################################################
# Population #
########################################################################

# Population OMM #############################
# 2022-12-08: HYDE 3.2 + Gapminder + UN WPP 2022
Expand Down Expand Up @@ -111,9 +111,9 @@ steps:
data://grapher/demography/2023-07-03/world_population_comparison:
- data://garden/demography/2023-06-27/world_population_comparison

####################################
# Life expectancy ##################
####################################
########################################################################
# Life expectancy #
########################################################################

# HMD
data://meadow/hmd/2023-09-19/hmd:
Expand Down Expand Up @@ -220,53 +220,9 @@ steps:
data://grapher/un/2024-03-14/un_wpp_most:
- data://garden/un/2024-03-14/un_wpp_most

# Migration UN DESA
data://meadow/un/2024-07-16/migrant_stock:
- snapshot://un/2024-07-16/migrant_stock_dest_origin.xlsx
- snapshot://un/2024-07-16/migrant_stock_origin.xlsx
- snapshot://un/2024-07-16/migrant_stock_dest.xlsx
- snapshot://un/2024-07-16/migrant_stock_age_sex.xlsx
data://garden/un/2024-07-16/migrant_stock:
- data://meadow/un/2024-07-16/migrant_stock
data://grapher/un/2024-07-16/migrant_stock:
- data://garden/un/2024-07-16/migrant_stock

# Migration UN DESA (flows)
data://grapher/migration/2024-11-20/migrant_stock_flows:
- data://garden/un/2024-07-16/migrant_stock

# Internal displacement monitoring centre
data://meadow/idmc/2024-08-02/internal_displacement:
- snapshot://idmc/2024-08-02/internal_displacement.xlsx
- data://garden/demography/2024-07-15/population
data://grapher/idmc/2024-08-02/internal_displacement:
- data://meadow/idmc/2024-08-02/internal_displacement

# UNHCR refugee data
data://meadow/un/2024-07-25/refugee_data:
- snapshot://un/2024-07-25/refugee_data.zip
data://garden/un/2024-07-25/refugee_data:
- data://meadow/un/2024-07-25/refugee_data
- data://garden/demography/2024-07-15/population
- data://garden/un/2024-07-25/resettlement
data://grapher/un/2024-07-25/refugee_data:
- data://garden/un/2024-07-25/refugee_data

# UNHCR resettlement data
data://meadow/un/2024-07-25/resettlement:
- snapshot://un/2024-07-25/resettlement.zip
data://garden/un/2024-07-25/resettlement:
- data://meadow/un/2024-07-25/resettlement
- data://garden/demography/2024-07-15/population

# Child migration (UNICEF)
data://meadow/unicef/2024-07-30/child_migration:
- snapshot://unicef/2024-07-30/child_migration.csv
data://garden/unicef/2024-07-30/child_migration:
- data://meadow/unicef/2024-07-30/child_migration
- data://garden/demography/2024-07-15/population
data://grapher/unicef/2024-07-30/child_migration:
- data://garden/unicef/2024-07-30/child_migration
########################################################################
# Fertility #
########################################################################

# Mothers by decadal age-group
data://garden/un/2024-10-01/births_by_age:
Expand All @@ -281,3 +237,11 @@ steps:
- data://meadow/hmd/2024-11-19/hfd
data://grapher/hmd/2024-11-19/hfd:
- data://garden/hmd/2024-11-19/hfd

# Multiple births
data://meadow/demography/2024-11-26/multiple_births:
- snapshot://demography/2024-11-26/multiple_births.7z
data://garden/demography/2024-11-26/multiple_births:
- data://meadow/demography/2024-11-26/multiple_births
data://grapher/demography/2024-11-26/multiple_births:
- data://garden/demography/2024-11-26/multiple_births
23 changes: 9 additions & 14 deletions dag/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ steps:
data://grapher/homicide/2024-10-30/unodc:
- data://garden/homicide/2024-10-30/unodc


#
# UN
data://grapher/un/2022-07-11/un_wpp:
Expand Down Expand Up @@ -321,8 +320,6 @@ steps:
data://grapher/terrorism/2023-07-20/global_terrorism_database:
- data://garden/terrorism/2023-07-20/global_terrorism_database



# Colonial Dates Dataset (COLDAT)
data://meadow/harvard/2023-09-18/colonial_dates_dataset:
- snapshot://harvard/2023-09-18/colonial_dates_dataset.csv
Expand Down Expand Up @@ -355,7 +352,6 @@ steps:
data://garden/gapminder/2023-09-21/under_five_mortality:
- data://meadow/gapminder/2023-09-21/under_five_mortality


# Older vintage UN IGME (with longer time-series)
data://meadow/un/2018/igme:
- snapshot://un/2018/igme.csv
Expand Down Expand Up @@ -763,7 +759,7 @@ steps:
data-private://grapher/language/2024-07-17/ethnologue:
- data-private://garden/language/2024-07-17/ethnologue

# Child Mortality Estimates - UN IGME
# Child Mortality Estimates - UN IGME
data://meadow/un/2024-09-11/igme:
- snapshot://un/2024-09-11/igme.zip
data://garden/un/2024-09-11/igme:
Expand All @@ -774,17 +770,15 @@ steps:
data://grapher/un/2024-09-11/igme:
- data://garden/un/2024-09-11/igme


# Long-run child mortality, Gapminder + UN IGME
# Long-run child mortality, Gapminder + UN IGME
data://garden/un/2024-09-16/long_run_child_mortality:
- data://garden/un/2024-09-11/igme
- data://garden/gapminder/2023-09-18/under_five_mortality
- data://garden/gapminder/2023-09-21/under_five_mortality
data://grapher/un/2024-09-16/long_run_child_mortality:
- data://garden/un/2024-09-16/long_run_child_mortality


# UN SDG (2024)
# UN SDG (2024)
data://meadow/un/2024-08-27/un_sdg:
- snapshot://un/2024-08-27/un_sdg.feather
data://garden/un/2024-08-27/un_sdg:
Expand All @@ -794,7 +788,7 @@ steps:
data://grapher/un/2024-08-27/un_sdg:
- data://garden/un/2024-08-27/un_sdg

# OECD Official Development Assistance (ODA)
# OECD Official Development Assistance (ODA)
data://meadow/oecd/2024-08-21/official_development_assistance:
- snapshot://oecd/2024-08-21/official_development_assistance_dac1.zip
- snapshot://oecd/2024-08-21/official_development_assistance_dac2a.zip
Expand All @@ -806,23 +800,23 @@ steps:
data://grapher/oecd/2024-08-21/official_development_assistance:
- data://garden/oecd/2024-08-21/official_development_assistance

# Oil Spills
# Oil Spills
data://meadow/itopf/2024-10-16/oil_spills:
- snapshot://itopf/2024-10-16/oil_spills.pdf
data://garden/itopf/2024-10-16/oil_spills:
- data://meadow/itopf/2024-10-16/oil_spills
data://grapher/itopf/2024-10-16/oil_spills:
- data://garden/itopf/2024-10-16/oil_spills

# UN SD census data
# UN SD census data
data://meadow/un/2024-10-21/census_dates:
- snapshot://un/2024-10-21/census_dates.csv
data://garden/un/2024-10-21/census_dates:
- data://meadow/un/2024-10-21/census_dates
data://grapher/un/2024-10-21/census_dates:
- data://garden/un/2024-10-21/census_dates

# World Peace Foundation - Famines
# World Peace Foundation - Famines
data://meadow/wpf/2024-10-03/famines:
- snapshot://wpf/2024-10-03/famines.xlsx
data://garden/wpf/2024-10-03/famines:
Expand Down Expand Up @@ -861,7 +855,7 @@ steps:
data-private://grapher/owid/latest/ig_countries:
- data-private://garden/owid/latest/ig_countries

# Migration between regions, based on UN DESA flows
# Migration between regions, based on UN DESA flows
data://garden/migration/2024-11-18/migration_between_regions:
- data://garden/un/2024-07-16/migrant_stock
- data://garden/regions/2023-01-01/regions
Expand Down Expand Up @@ -913,3 +907,4 @@ include:
- dag/chartbook.yml
- dag/minerals.yml
- dag/tourism.yml
- dag/migration.yml
44 changes: 44 additions & 0 deletions dag/migration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
steps:
# Migration UN DESA
data://meadow/un/2024-07-16/migrant_stock:
- snapshot://un/2024-07-16/migrant_stock_dest_origin.xlsx
- snapshot://un/2024-07-16/migrant_stock_origin.xlsx
- snapshot://un/2024-07-16/migrant_stock_dest.xlsx
- snapshot://un/2024-07-16/migrant_stock_age_sex.xlsx
data://garden/un/2024-07-16/migrant_stock:
- data://meadow/un/2024-07-16/migrant_stock
data://grapher/un/2024-07-16/migrant_stock:
- data://garden/un/2024-07-16/migrant_stock

# Internal displacement monitoring centre
data://meadow/idmc/2024-08-02/internal_displacement:
- snapshot://idmc/2024-08-02/internal_displacement.xlsx
- data://garden/demography/2024-07-15/population
data://grapher/idmc/2024-08-02/internal_displacement:
- data://meadow/idmc/2024-08-02/internal_displacement

# UNHCR refugee data
data://meadow/un/2024-07-25/refugee_data:
- snapshot://un/2024-07-25/refugee_data.zip
data://garden/un/2024-07-25/refugee_data:
- data://meadow/un/2024-07-25/refugee_data
- data://garden/demography/2024-07-15/population
- data://garden/un/2024-07-25/resettlement
data://grapher/un/2024-07-25/refugee_data:
- data://garden/un/2024-07-25/refugee_data

# UNHCR resettlement data
data://meadow/un/2024-07-25/resettlement:
- snapshot://un/2024-07-25/resettlement.zip
data://garden/un/2024-07-25/resettlement:
- data://meadow/un/2024-07-25/resettlement
- data://garden/demography/2024-07-15/population

# Child migration (UNICEF)
data://meadow/unicef/2024-07-30/child_migration:
- snapshot://unicef/2024-07-30/child_migration.csv
data://garden/unicef/2024-07-30/child_migration:
- data://meadow/unicef/2024-07-30/child_migration
- data://garden/demography/2024-07-15/population
data://grapher/unicef/2024-07-30/child_migration:
- data://garden/unicef/2024-07-30/child_migration
Binary file added docs/assets/annotations-chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion docs/guides/etl-tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ You can adapt the function to your needs, and perform different kinds of expansi
)
```


## Deprecate code
Our codebase has lots of code. Some of it may no longer be maintained or used. To avoid confusion, it is a good practice to slowly deprecate code. This can be done by adding a deprecation warning to the code, and then removing it after a certain period of time:

Expand All @@ -149,3 +148,23 @@ from deprecated import deprecated
Make sure to point users to an alternative function or method that they can use instead.

Please deprecate function with care, and make sure to check if the function is widely used, and communicate the deprecation to the team.

## Add entity annotations to your dataset
Just add the field `display.entityAnnotationsMap` to the desired indicator.

```yaml
display:
entityAnnotationsMap: |-
Spain: Some annotation
France: Another annotation
```

!!! note "Space is limited"

The space for annotations in charts is limited. Please be mindful and keep the annotations short and to the point. 2-4 words is usually enough, ideally 2.


<figure markdown="span">
<img src="../../assets/annotations-chart.png" alt="OWID chart with annotations" style="width:80%;">
<figcaption>Example chart with entity annotations. Note that the space for annotations.</figcaption>
</figure>
2 changes: 1 addition & 1 deletion docs/guides/pull-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Once you've created a PR, the automation user [@owidbot](https://github.com/owid
- data-diff: Changes introduced in the data compared to PRODUCTION.

<figure markdown="span">
<img src="../../assets/pr-1.png" alt="Chart Upgrader" style="width:50%;">
<img src="../../assets/pr-1.png" alt="Chart Upgrader" style="width:80%;">
<figcaption>PR, and [comment by @owidbot](https://github.com/owid/etl/pull/3563#issuecomment-2485397175), as of 19th November 2024</figcaption>
</figure>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"Australia": "Australia",
"Austria": "Austria",
"Canada": "Canada",
"Chile": "Chile",
"Czech Republic": "Czechia",
"Denmark": "Denmark",
"Finland": "Finland",
"France": "France",
"Germany": "Germany",
"Greece": "Greece",
"Iceland": "Iceland",
"Italy": "Italy",
"Japan": "Japan",
"Lithuania": "Lithuania",
"Netherlands": "Netherlands",
"New Zealand": "New Zealand",
"Norway": "Norway",
"Republic of Korea": "South Korea",
"Spain": "Spain",
"Sweden": "Sweden",
"Switzerland": "Switzerland",
"United States": "United States",
"Uruguay": "Uruguay",
"UK-England and Wales": "England and Wales",
"UK-Scotland": "Scotland"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[
]
Loading