G-Node / G-Node/nixworks

Conditional module availability based on available dependencies

Open
#18 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
0
Forks
5
PR merge metrics
No merged PRs in 30d

Description

One of the initial ideas we discussed for this package was that each submodule would have a different set of dependencies and they would all be "optional dependencies". For instance, the `nixworks.table` module shouldn't be available if Pandas isn't installed and the `nixworks.plotter` shouldn't be available without Matplotlib. The general idea is that users shouldn't need to install Pandas if they only want the plotting and vice versa. This will be more important as more modules get added.

We should figure out a nice way to conditionally enable submodules based on available dependencies. This could be a simple try catch in the module's files (e.g., in nixworks/table/table.py):
```python
try:
import pandas
except ImportError:
raise ImportError("Module 'table' requires Pandas")
```

but perhaps it would be nicer if the top-level `__init__.py` did all the import checking and marked modules available or not with appropriate error messages.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing nixworks/table/table.py and the package-level __init__.py, then inspect how the table and plotter submodules are currently imported. Compare the proposed module-level checks with top-level import handling for Pandas and Matplotlib. Done means optional dependencies no longer block unrelated submodules and missing dependencies produce appropriate errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.