gridfm / gridfm/gridfm-graphkit
Bug: `ModuleNotFoundError: No module named 'torch_scatter'` when importing from `gridfm_graphkit`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 105
- Forks
- 36
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 9
Description
Bug: ModuleNotFoundError: No module named 'torch_scatter' when importing from gridfm_graphkit
Summary
Any import from gridfm_graphkit — even from submodules that do not themselves use torch_scatter (e.g. gridfm_graphkit.datasets.postprocessing) — triggers a top-level ModuleNotFoundError for torch_scatter because the package __init__.py eagerly imports the entire task tree, which in turn imports torch_scatter unconditionally.
Reproduction
from gridfm_graphkit.datasets.postprocessing import (
compute_branch_currents_kA,
compute_loading,
)
Full Traceback
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../gridfm_graphkit/__init__.py", line 2, in <module>
import gridfm_graphkit.tasks.base_task
File ".../gridfm_graphkit/tasks/__init__.py", line 1, in <module>
from gridfm_graphkit.tasks.pf_task import PowerFlowTask
File ".../gridfm_graphkit/tasks/pf_task.py", line 21, in <module>
from gridfm_graphkit.tasks.reconstruction_tasks import ReconstructionTask
File ".../gridfm_graphkit/tasks/reconstruction_tasks.py", line 1, in <module>
from gridfm_graphkit.io.param_handler import load_model, get_loss_function
File ".../gridfm_graphkit/io/param_handler.py", line 2, in <module>
from gridfm_graphkit.training.loss import MixedLoss
File ".../gridfm_graphkit/training/__init__.py", line 1, in <module>
from gridfm_graphkit.training.loss import (
File ".../gridfm_graphkit/training/loss.py", line 6, in <module>
from torch_scatter import scatter_add
ModuleNotFoundError: No module named 'torch_scatter'
Root Cause
torch_scatter is not listed as a dependency in pyproject.toml yet it is imported at module level in at least the following files:
- gridfm_graphkit/training/loss.py:6
- gridfm_graphkit/models/utils.py:3
- gridfm_graphkit/models/gnn_heterogeneous_gns.py:6
- gridfm_graphkit/tasks/se_task.py:22
- gridfm_graphkit/tasks/opf_task.py:40
Expected Behaviour
Either:
- torch-scatter is added to [project.dependencies], or
- the top-level init.py no longer eagerly imports the full task tree, so that lightweight submodules (e.g. datasets.postprocessing) can be used without pulling in heavy training/model dependencies.
Environment
gridfm-graphkit version: 0.8.1
Python: 3.10 – 3.12
Branch: chore/torch-scatter-dep
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with pyproject.toml and gridfm_graphkit/init.py, then trace the imports named in the traceback through tasks/init.py, training/loss.py, and the listed model and task files. Reproduce the lightweight datasets.postprocessing import in an environment without torch_scatter, then verify that the chosen dependency or import strategy removes the unexpected failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100