Update notebook, tests and linkchecker - #95
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the capacity.ipynb example notebook’s data-join logic when combining asset_capacities.csv with assets.csv prior to aggregating capacity by milestone year, agent, and process.
Changes:
- Adjusted the merge key used to join
asset_capacitieswithassetsin the capacity calculation workflow.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (3)
Previously missed (1) — in code that hasn't changed since the last review.
muse2_data_analysis/helpers.py:18
get_example_output_dir()is documented to return a directory, but it only checks_OUTPUT_DIR.exists(). If a regular file exists at that path, this will return a non-directory and downstreampd.read_csv(_OUTPUT_DIR / ...)will fail in a confusing way. Consider using_OUTPUT_DIR.is_dir()(and possibly raising a clear error if the path exists but is not a directory).
"""
if _OUTPUT_DIR.exists():
return _OUTPUT_DIR
# Run the example model
run_muse2("example", "run", EXAMPLE_NAME, "--output-dir", str(_OUTPUT_DIR))
muse2_data_analysis/helpers.py:10
- This PR removes
get_example_input_dir()fromhelpers.py. Since it wasn’t underscored, it’s a public API and downstream notebook/users may rely on it; removing it is a breaking change. Consider keeping it as a backwards-compatible alias (e.g., returning the same path or raising a clear deprecation error) or documenting the breaking change and bumping the version accordingly.
DATA_DIR = Path(__file__).parent.parent.absolute() / "data"
EXAMPLE_NAME = "muse1_default"
_OUTPUT_DIR = DATA_DIR / f"{EXAMPLE_NAME}"
notebooks/capacity.ipynb:60
- This change alters the join keys from
["asset_id", "group_id"]to just"asset_id", which can silently change row cardinality (many-to-many merges) and therefore the aggregated capacities. To make the intended relationship explicit and fail fast if assumptions change, consider addingvalidate="many_to_one"(or anassert assets["asset_id"].is_unique) when merging.
"assets = pd.read_csv(OUTPUT_DIR / \"assets.csv\")\n",
"asset_capacities = pd.read_csv(OUTPUT_DIR / \"asset_capacities.csv\")\n",
"\n",
"merged = asset_capacities.merge(assets, on=\"asset_id\")\n",
"agg_capacities = merged.groupby([\"milestone_year\", \"agent_id\", \"process_id\"])[\n",
dalonsoa
approved these changes
Aug 25, 2026
dalonsoa
left a comment
Contributor
There was a problem hiding this comment.
Looks good and works as expected 👍
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR makes all the necessary changes to get that magic green tick ✅:
group_idcolumnexample runsubcommand, rather than having to extract the example model firstClose #92
Type of change
Key checklist
python -m pytest)pre-commit run --all-files)Further checks
(Indicate issue here: # (issue))