Skip to content

Update notebook, tests and linkchecker - #95

Merged
tsmbland merged 4 commits into
mainfrom
update_notebooks
Aug 25, 2026
Merged

Update notebook, tests and linkchecker#95
tsmbland merged 4 commits into
mainfrom
update_notebooks

Conversation

@tsmbland

@tsmbland tsmbland commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Description

This PR makes all the necessary changes to get that magic green tick ✅:

  • fix notebook referring to the now removed group_id column
  • linkchecker was failing - I believe stack exchange doesn't like bots, so I've excluded these links
  • not strictly necessary, but since input files are now copied to the output folder by MUSE, we no longer need special handling for input files. This also means we can run the example model directly using the example run subcommand, rather than having to extract the example model first

Close #92

Type of change

  • Documentation (non-breaking change that adds or improves the documentation)
  • New feature (non-breaking change which adds functionality)
  • Optimization (non-breaking, back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (whatever its nature)

Key checklist

  • All tests pass (eg. python -m pytest)
  • Pre-commit hooks run successfully (eg. pre-commit run --all-files)

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added or an issue has been opened to tackle that in the future.
    (Indicate issue here: # (issue))

Copilot AI lite review requested due to automatic review settings August 25, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_capacities with assets in the capacity calculation workflow.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread notebooks/capacity.ipynb
Copilot AI review requested due to automatic review settings August 25, 2026 10:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread muse2_data_analysis/helpers.py
Copilot AI review requested due to automatic review settings August 25, 2026 10:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 downstream pd.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() from helpers.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 adding validate="many_to_one" (or an assert 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",

@tsmbland tsmbland changed the title Update notebooks Update notebook, tests and linkchecker Aug 25, 2026

@dalonsoa dalonsoa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works as expected 👍

@tsmbland
tsmbland merged commit 905a7e8 into main Aug 25, 2026
6 checks passed
@tsmbland
tsmbland deleted the update_notebooks branch August 25, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update notebooks to work with MUSE2 main in time for v2.2.0 release

3 participants