Fix forest fire networkx dependency
GSoC contributor checklist
Context & motivation
I am a beginner in open source, I went through many organizations and picked this particular organization and this particular project as it is simple and aligned with the skills I am good at.I was exploring the mesa-examples repository as part of my GSoC 2026 application for the Mesa Examples Revival project. I ran all 22 examples to understand the current state of the repo. When I ran the forest_fire example, I got a ModuleNotFoundError for networkx. I checked the requirements.txt and networkx was missing, so I added it.
What I learned
I learned how Python dependency management works with requirements.txt. I also learned how to use git rebase to clean up a PR branch, and how the GitHub PR review process works. This was my first open source contribution. I am polishing my basic knowledge of git commands. This gave me an exciting opportunity to learn and explore more of git and github and open source projects
Learning repo
🔗 My learning repo: https://github.com/GITUSERMANOLYA/GSoC-learning-space 🔗 Relevant model(s): N/A
Readiness checks
- [x] This PR addresses an agreed-upon problem (linked issue or discussion with maintainer approval), or is a small/trivial fix
- [x] I have read the contributing guide and deprecation policy
- [x] I have performed a self-review
- [x] Another GSoC contributor has reviewed this PR: @Harshini2411
- [x] Tests pass locally
- [x] Code is formatted
Thanks for the PR. Could you git rebase it? It looks like it now changes a lot, which it probably doesn't.
Thanks for the PR. Could you git rebase it? It looks like it now changes a lot, which it probably doesn't.
Hi! I'm new to using Git. I've rebased the branch. The diff only contains the single networkx line addition to requirements.txt. Let me know if anything else is needed!
For some reason 3 other commits are included. I normally sync the upstream main branch and then rebase my PR branch on the upstream main branch.
Hey! Reviewed this PR 👋 The fix itself is correct, networkx was definitely missing from requirements.txt and this is the right place to add it. One thing though your PR seems to have picked up 3 extra commits that aren't related to this fix (the CI update, M/M/c queue example, and README update). That's probably why the diff shows +312/-18 instead of just +1 line. @EwoutH already mentioned this too. You'd need to rebase onto upstream main to clean those up:
git remote add upstream https://github.com/projectmesa/mesa-examples
git fetch upstream
git rebase upstream/main
git push --force-with-lease origin fix-forest-fire-networkx-dependency
Once that's sorted the PR should be good to merge! Happy to take another look after the rebase 🙂
Done! Rebased onto upstream/main. The diff now shows only the single +networkx line addition.Thanks for the help!! EwoutH and Harshini2411!
Looks good now! The rebase is clean, diff is exactly the one line it should be, and the fix is correct. LGTM and ready to merge! 🙌
I see forest_fire is based on Grid then why do we need networkx as dependency? Am I missing something?
the forest_fire model is a pure grid-based cellular automaton with no network or graph structure, so networkx shouldn't be needed anywhere in the code. The dependency looks like it was listed by mistake. @GITUSERMANOLYA can you confirm networkx isn't imported anywhere in the model or notebook? If so, this PR is correct in removing it.
Actually when I ran python -m solara run app.py in the forest_fire folder it threw ModuleNotFoundError: No module named 'networkx'. Adding networkx to requirements.txt fixes this error. Hence I mentioned this fix.
checkout https://github.com/mesa/mesa/issues/3596
Good catch @codebreaker32! forest_fire doesn't use networkx directly, but the error still occurs because import mesa triggers a top-level import networkx via discrete_space to network.py. That said, you're right to question this adding it to requirements.txt is a workaround. The root fix is being tracked in projectmesa/mesa#3598, which moves the import lazily inside Network.init. Once that merges, this requirement may no longer be needed here.