Skip to content

tools.costs requires plotnine dependency #323

Open
@glatterf42

Description

@glatterf42

As discovered in #322, when installing message-ix-models in a fresh virtual environment from PyPI and trying to run

from message_ix_models.tools.costs.config import Config

I receive a ModuleNotFoundError: No module named 'plotnine'.

Full traceback
>>> from message_ix_models.tools.costs.config import Config
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fridolin/.virtualenvs/fix-git-lfs-pointers/lib/python3.12/site-packages/message_ix_models/__init__.py", line 30, in <module>
    Context()
  File "/home/fridolin/.virtualenvs/fix-git-lfs-pointers/lib/python3.12/site-packages/message_ix_models/util/context.py", line 118, in __init__
    kwargs[key] = cls(**values)
                  ^^^^^^^^^^^^^
  File "<string>", line 3, in __init__
  File "/home/fridolin/.virtualenvs/fix-git-lfs-pointers/lib/python3.12/site-packages/message_ix_models/report/config.py", line 26, in _default_callbacks
    from message_ix_models.report import plot
  File "/home/fridolin/.virtualenvs/fix-git-lfs-pointers/lib/python3.12/site-packages/message_ix_models/report/plot.py", line 15, in <module>
    import plotnine as p9
ModuleNotFoundError: No module named 'plotnine'

For installation, I simply ran pip install message-ix-models because there is no dependency section for tools.costs, indicating that no special dependencies are required.

Manually installing plotnine fixes the issue. Note, though, that this is only testing a part of tools.costs, so other parts of the module may required additional dependencies that I haven't discovered so far.

So to resolve this issue, I suggest to add a tools.costs (or maybe tools-costs or just costs) section to pyproject.toml and list plotnine in there.

To completely resolve the issue of any additional dependencies, I suggest running the full demo file and noting what else comes up as missing. Running the test suite is not really an option, I think, since that requires the tests section, which already brings in report and transport, including plotnine, so with that, we would even miss the dependency responsible for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    costs`.tools.costs`/cost data preparation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions