Skip to content

Commit

Permalink
Make scenario inclusion stage save to scripts dir
Browse files Browse the repository at this point in the history
  • Loading branch information
collijk committed Dec 24, 2024
1 parent c67e151 commit f54122a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ name: Build and Deploy Docs

on:
workflow_dispatch:
push:
pull_request:
branches:
- main
types:
- closed

jobs:
build-and-deploy-docs:
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
---

**Documentation**: [https://ihmeuw.github.io/climate-data](https://ihmeuw.github.io/climate-data)

**Source Code**: [https://github.com/ihmeuw/climate-data](https://github.com/ihmeuw/climate-data)

---
Expand Down
4 changes: 3 additions & 1 deletion scripts/gen_data_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
"""

inclusion_metadata = cdata.load_scenario_inclusion_metadata()
inclusion_metadata = pd.read_parquet(
Path(__file__).parent / "scenario_inclusion_metadata.parquet"
)
source_table = inclusion_metadata.groupby("source").sum()

total_counts = pd.concat(
Expand Down
Binary file added scripts/scenario_inclusion_metadata.parquet
Binary file not shown.
15 changes: 11 additions & 4 deletions src/climate_data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,24 @@ def results_metadata(self) -> Path:

def save_scenario_metadata(self, df: pd.DataFrame) -> None:
path = self.results_metadata / "scenario_metadata.parquet"
touch(path, exist_ok=True)
if path.exists():
path.unlink()
touch(path)
df.to_parquet(path)

def load_scenario_metadata(self) -> pd.DataFrame:
path = self.results_metadata / "scenario_metadata.parquet"
return pd.read_parquet(path)

def save_scenario_inclusion_metadata(self, df: pd.DataFrame) -> None:
path = self.results_metadata / "scenario_inclusion_metadata.parquet"
touch(path, exist_ok=True)
df.to_parquet(path)
# Need to save to our scripts directory for doc building
scripts_root = Path(__file__).parent.parent / "scripts"
for root_dir in [self.results_metadata, scripts_root]:
path = root_dir / "scenario_inclusion_metadata.parquet"
if path.exists():
path.unlink()
touch(path)
df.to_parquet(path)

def load_scenario_inclusion_metadata(self) -> pd.DataFrame:
path = self.results_metadata / "scenario_inclusion_metadata.parquet"
Expand Down

0 comments on commit f54122a

Please sign in to comment.