Skip to content

Commit

Permalink
Merge pull request #1304 from cal-itp/test-new-index
Browse files Browse the repository at this point in the history
Check portfolio index for removed portfolios
  • Loading branch information
tiffanychu90 authored Nov 25, 2024
2 parents a9d40b3 + 5f922c7 commit 0ff0f18
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 64 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,6 @@ dmypy.json

# Macos
.DS_Store

# Local Netlify folder
.netlify
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ build_portfolio_site:
#git rm portfolio/$(site)/ -rf
python portfolio/portfolio.py clean $(site)
python portfolio/portfolio.py build $(site) --deploy
python portfolio/portfolio.py clean $(site)
git add portfolio/sites/$(site).yml
#make production_portfolio

Expand Down Expand Up @@ -36,21 +35,21 @@ build_ntd_report:

build_gtfs_digest:
$(eval export site = gtfs_digest)
#cd data-analyses/rt_segment_speeds && pip install -r requirements.txt && cd ../_shared_utils && make setup_env && cd ..
#cd rt_segment_speeds && pip install -r requirements.txt && cd ../_shared_utils && make setup_env && cd ..
#cd gtfs_digest/ && python deploy_portfolio_yaml.py && make assemble_data && cd ..
make build_portfolio_site
make git_check_sections

build_district_digest:
$(eval export site = district_digest)
#cd data-analyses/rt_segment_speeds && pip install -r requirements.txt && cd ../_shared_utils && make setup_env && cd ..
cd gtfs_digest/ && python deploy_district_yaml.py district && cd ..
#cd rt_segment_speeds && pip install -r requirements.txt && cd ../_shared_utils && make setup_env && cd ..
#cd gtfs_digest/ && python deploy_district_yaml.py district && cd ..
make build_portfolio_site
make git_check_no_sections

build_legislative_district_digest:
$(eval export site = legislative_district_digest)
#cd data-analyses/rt_segment_speeds && pip install -r requirements.txt && cd ../_shared_utils && make setup_env && cd ..
#cd rt_segment_speeds && pip install -r requirements.txt && cd ../_shared_utils && make setup_env && cd ..
cd gtfs_digest/ && python deploy_district_yaml.py legislative_district && cd ..
make build_portfolio_site
make git_check_no_sections
Expand Down
3 changes: 2 additions & 1 deletion _shared_utils/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ altair==5.3.0
altair-transform==0.2.0
gtfs-segments==0.1.0
pyairtable==2.2.2
great_tables==0.6.1
great_tables==0.14.0
omegaconf==2.3.0 # better yaml configuration
polars==0.20.29
quarto-cli==1.4.554
quarto==0.1.0
typing_extensions==4.12.2
28 changes: 28 additions & 0 deletions gtfs_digest/_report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pandas as pd
import yaml

from great_tables import GT, loc, style

def labeling(word: str) -> str:
"""
Expand Down Expand Up @@ -107,3 +108,30 @@ def transpose_summary_stats(
}).T.reset_index().rename(columns = {0: "value"})

return subset_df2


def great_table_formatting(my_table: GT) -> GT:
"""
Common great table formatting needed for district
and legislative district digest.
"""
my_table = (
my_table
.opt_align_table_header(align="center")
.tab_style(
style=style.text(size="14px"),
locations=loc.body())
.tab_options(
container_width = "100%",
table_background_color="white",
table_body_hlines_style="none",
table_body_vlines_style="none",
heading_background_color="white",
column_labels_background_color="white",
row_group_background_color="white",
stub_background_color="white",
source_notes_background_color="white"
)
)

return my_table
7 changes: 2 additions & 5 deletions gtfs_digest/deploy_district_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,11 @@ def overwrite_yaml(
f"{RT_SCHED_GCS}{OPERATOR_FILE}.parquet",
columns = ["caltrans_district"]
).dropna(subset="caltrans_district").drop_duplicates()

chapter_values_orig = sorted(list(df.caltrans_district))
chapter_values = [f"District {i}" for i in chapter_values_orig]


portfolio_utils.create_portfolio_yaml_chapters_no_sections(
DISTRICT_SITE,
chapter_name = "district",
chapter_values = chapter_values
chapter_values = sorted(list(df.caltrans_district))
)

elif name == "legislative_district":
Expand Down
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
9 changes: 4 additions & 5 deletions portfolio/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import subprocess
import sys
from pathlib import Path
from typing import Dict, List, Optional
from typing import Any, Dict, List, Optional

import humanize
import papermill as pm
Expand Down Expand Up @@ -61,7 +61,7 @@ def parameterize_filename(i: int, old_path: Path, params: Dict) -> Path:


class Chapter(BaseModel):
caption: Optional[str]
caption: Optional[Any]
notebook: Optional[Path] = None
params: Dict = {}
sections: List[Dict] = []
Expand Down Expand Up @@ -183,7 +183,7 @@ def toc(self):


class Part(BaseModel):
caption: Optional[str] = None
caption: Optional[Any] = None
notebook: Optional[Path] = None
params: Dict = {}
chapters: List[Chapter] = []
Expand Down Expand Up @@ -433,7 +433,6 @@ def build(
if errors:
typer.secho(f"{len(errors)} errors encountered during papermill execution", fg=typer.colors.RED)
sys.exit(1)



if __name__ == "__main__":
app()
24 changes: 12 additions & 12 deletions portfolio/sites/district_digest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ parts:
- caption: Introduction
- chapters:
- params:
district: District 01 - Eureka
district: 01 - Eureka
- params:
district: District 02 - Redding
district: 02 - Redding
- params:
district: District 03 - Marysville
district: 03 - Marysville
- params:
district: District 04 - Oakland
district: 04 - Oakland
- params:
district: District 05 - San Luis Obispo
district: 05 - San Luis Obispo
- params:
district: District 06 - Fresno
district: 06 - Fresno
- params:
district: District 07 - Los Angeles
district: 07 - Los Angeles
- params:
district: District 08 - San Bernardino
district: 08 - San Bernardino
- params:
district: District 09 - Bishop
district: 09 - Bishop
- params:
district: District 10 - Stockton
district: 10 - Stockton
- params:
district: District 11 - San Diego
district: 11 - San Diego
- params:
district: District 12 - Irvine
district: 12 - Irvine
readme: ./gtfs_digest/README.md
title: District GTFS Digest
24 changes: 12 additions & 12 deletions portfolio/sites/ha_starterkit_district.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ parts:
- caption: Introduction
- chapters:
- params:
district: "1"
district: 1
- params:
district: "2"
district: 2
- params:
district: "3"
district: 3
- params:
district: "4"
district: 4
- params:
district: "5"
district: 5
- params:
district: "6"
district: 6
- params:
district: "7"
district: 7
- params:
district: "8"
district: 8
- params:
district: "9"
district: 9
- params:
district: "10"
district: 10
- params:
district: "11"
district: 11
- params:
district: "12"
district: 12
readme: ./ha_portfolio/README.md
title: Testing a Portfolio

0 comments on commit 0ff0f18

Please sign in to comment.