Skip to content

Fix COBRA install: add scikit-learn dependency + revamp install docs (#391) - #392

Merged
katehoffshutta merged 3 commits into
netZoo:develfrom
marouenbg:fix/cobra-sklearn-dep-391
Aug 12, 2026
Merged

Fix COBRA install: add scikit-learn dependency + revamp install docs (#391)#392
katehoffshutta merged 3 commits into
netZoo:develfrom
marouenbg:fix/cobra-sklearn-dep-391

Conversation

@marouenbg

@marouenbg marouenbg commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #391.

Problem

A user following the documented install (git clonecd netZooPypip3 install -e .) could not run COBRA.

netZooPy/cobra/cobra.py imports from sklearn.linear_model import LinearRegression, Lasso, but setup.py did not list scikit-learn in install_requires (it was only in requirements.txt). Because netZooPy/__init__.py eagerly runs from netZooPy import cobra, a clean pip install -e . left import netZooPy itself broken with ModuleNotFoundError: No module named 'sklearn', not just COBRA.

Separately, the reporter's No module named 'netZooPy.cobra' / (unknown location) errors come from an environment pitfall: running Python from the clone's parent directory (or a Jupyter/VS Code kernel that isn't the install env) makes the cloned netZooPy folder resolve as an empty namespace package that shadows the installed one.

Changes

  • setup.py: add scikit-learn to install_requires (the substantive fix).
  • README.md: keep it minimal — only adds from netZooPy.cobra import cobra to the usage example.
  • docs/install/index.md: revamp the install guide —
    • sync the dependency list with setup.py (was missing h5py, joblib, statsmodels, scikit-learn, click, tables, torch) and note pip installs them automatically; document CuPy as the optional GPU dependency;
    • recommend a virtual environment;
    • expand the Troubleshooting section to cover both failure modes above.

Troubleshooting content lives in the install guide (where users look) rather than the README.

Verification

  • Clean python -m venv + pip install -e . now auto-installs scikit-learn; import netZooPy and from netZooPy.cobra import cobra both succeed; cobra() runs in nnls and MLE modes.
  • tests/test_cobra.py passes.
  • Audited every submodule's module-load-time imports: scikit-learn was the only undeclared hard dependency. cupy is correctly optional (lazy, GPU-only); patsy is guaranteed via statsmodels.

🤖 Generated with Claude Code

@marouenbg marouenbg closed this Jun 10, 2026
@marouenbg marouenbg reopened this Jun 10, 2026
netZooPy/cobra/cobra.py imports `from sklearn.linear_model import ...`,
but setup.py omitted scikit-learn from install_requires (it was only in
requirements.txt). Because netZooPy/__init__.py eagerly runs
`from netZooPy import cobra`, a fresh `pip install -e .` left not just
COBRA but `import netZooPy` itself broken with
`ModuleNotFoundError: No module named 'sklearn'`.

Also show the COBRA import in the README usage example.

Fixes netZoo#391

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@marouenbg
marouenbg force-pushed the fix/cobra-sklearn-dep-391 branch from 090bd20 to c594c0a Compare June 10, 2026 21:39
@marouenbg marouenbg changed the title Fix COBRA import: add scikit-learn dependency + document import shadowing (#391) Add scikit-learn to install_requires (#391) Jun 10, 2026
…#391)

- Update the dependency list to match setup.py install_requires (adds
  h5py, joblib, statsmodels, scikit-learn, click, tables, torch) and note
  that pip installs them automatically; document CuPy as the optional GPU
  dependency.
- Recommend installing inside a virtual environment.
- Expand the Troubleshooting section with the two failure modes behind
  issue netZoo#391: the namespace-shadowing import error (running from the
  clone's parent / wrong kernel) and the missing-scikit-learn error.

Keeps the README minimal; troubleshooting lives in the install guide.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@marouenbg marouenbg changed the title Add scikit-learn to install_requires (#391) Fix COBRA install: add scikit-learn dependency + revamp install docs (#391) Jun 10, 2026
@katehoffshutta katehoffshutta added the ai-contrib Some or all of this code is written by AI and requires a human review. label Aug 11, 2026
@katehoffshutta

Copy link
Copy Markdown
Contributor

Hi @marouenbg, we have added a requirement that all claude/AI code is human reviewed. The changes to setup.py and README.md are straightforward. Can you confirm the changes to docs/install/index.md look good to you? I am testing them on my end as well but prefer the author of the PR to also take a look.

@marouenbg

marouenbg commented Aug 11, 2026 via email

Copy link
Copy Markdown
Contributor Author

@katehoffshutta

Copy link
Copy Markdown
Contributor

Does the troubleshooting advice and suggested code for environments look good to you, though?

@marouenbg

marouenbg commented Aug 11, 2026 via email

Copy link
Copy Markdown
Contributor Author

@katehoffshutta katehoffshutta added the human-reviewed For code generated by AI, this label confirms someone human has reviewed it. label Aug 11, 2026
@katehoffshutta

Copy link
Copy Markdown
Contributor

Awesome, thanks!

@katehoffshutta
katehoffshutta merged commit fcb09e2 into netZoo:devel Aug 12, 2026
8 checks passed
@marouenbg

Copy link
Copy Markdown
Contributor Author

https://x.com/DustinTownsend/status/2087113602306064471

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-contrib Some or all of this code is written by AI and requires a human review. human-reviewed For code generated by AI, this label confirms someone human has reviewed it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants