generated from dataforgoodfr/d4g-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
126 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Build Graphs | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
generate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.12 | ||
- name: cache poetry install | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.local | ||
key: poetry-1.8.2-0 | ||
- uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.8.2 | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
- name: cache deps | ||
id: cache-deps | ||
uses: actions/cache@v2 | ||
with: | ||
path: .venv | ||
key: pydeps-${{ hashFiles('**/poetry.lock') }} | ||
- run: poetry install --no-interaction --no-root | ||
if: steps.cache-deps.outputs.cache-hit != 'true' | ||
- run: poetry install --no-interaction | ||
- run: poetry run python 12_pinkbombs_app/generate.py | ||
- id: files | ||
uses: jitterbit/get-changed-files@v1 | ||
with: | ||
format: 'csv' | ||
|
||
|
||
|
||
push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: 12_pinkbombs_app | ||
ref: 'main' | ||
token: ${{ secrets.D4GTECH_TOKEN }} | ||
path: './12_pinkbombs_app' | ||
- name: setup git config | ||
run: | | ||
git config user.name "Pinkbombs Bot" | ||
git config user.email "<>" | ||
- run : git add . | ||
- run: git commit -m "bot: update data" | ||
- run: git push origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import pinkbombs as pb | ||
import pandas as pd | ||
import graphs as pb | ||
|
||
|
||
MAPPING = { | ||
"salmon-collapse": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from config import MAPPING, MAPS | ||
import argparse | ||
|
||
|
||
def generate_graph(graph_name): | ||
if graph_name not in MAPPING: | ||
raise ValueError(f"Graph '{graph_name}' not found") | ||
df = MAPPING[graph_name]["parser"]( | ||
"data/" + MAPPING[graph_name]["filename"], | ||
) | ||
chart_obj = MAPPING[graph_name]["function"](df, *MAPPING[graph_name]["arguments"]) | ||
chart_obj.update_layout( | ||
hoverlabel=dict( | ||
bgcolor="white", | ||
) | ||
) | ||
return chart_obj.to_json() | ||
|
||
|
||
def generate_maps(map_name): | ||
if map_name not in MAPS: | ||
raise ValueError(f"Map '{map_name}' not found") | ||
df = MAPS[map_name]["parser"]( | ||
"data/" + MAPS[map_name]["filename"], | ||
) | ||
html_map = MAPS[map_name]["function"](df, *MAPS[map_name]["arguments"]) | ||
return html_map | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--root-dir", default="./", help="Directory where to save the generated data") | ||
parser.add_argument("--graph-data", default="*", help="Graphs to generate, default is all graphs") | ||
parser.add_argument("--map-data", default="*", help="Maps to generate, default is all maps") | ||
|
||
args = parser.parse_args() | ||
|
||
inverse_mapping = {v["filename"]: k for k, v in MAPPING.items()} | ||
|
||
if args.graph_data == "*": | ||
new_graphs = list(MAPPING.keys()) | ||
else: | ||
new_graphs = [inverse_mapping[filename] for filename in args.graph_data.split(",")] | ||
|
||
if args.map_data == "*": | ||
new_maps = list(MAPS.keys()) | ||
else: | ||
new_maps = [inverse_mapping[filename] for filename in args.map_data.split(",")] | ||
|
||
print("new_graphs", new_graphs) | ||
print("new_maps", new_maps) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from .viz import make_area_chart, make_area_single_chart | ||
from .viz import make_area_order_chart, make_bar_chart, make_area_order_chart_grouped | ||
from .viz import make_color_bar_chart, make_color_bar_chart2 | ||
from .viz import make_animated_bubble_map, make_treemap_chart | ||
from .viz import make_simple_bar_chart, make_simple_pie_chart | ||
from .viz import make_simple_box_chart, make_matrix_alternatives | ||
from .maps_viz import make_ras_bubble_map |