Skip to content

Split Plotting Functionality into Optional Package Extra #695

@roberthjaplaio

Description

@roberthjaplaio

Description:

I'm using pymoo in a FastAPI application where visualization and plotting are not required. However, pymoo currently has a direct dependency on matplotlib, which significantly increases the application's size and install time, especially in serverless or containerized environments.

I would like to request splitting the plotting-related functionality into an optional package extra, such as pymoo[visualization]. This would allow users who need plotting to install it explicitly, while those who don't (like in my FastAPI application) can avoid the unnecessary matplotlib dependency.

Benefits:

  • Reduced Application Size: Minimizes the footprint of pymoo in applications where plotting is not needed.
  • Faster Installation: Improves installation speed by avoiding the matplotlib dependency.
  • Cleaner Dependencies: Provides a more granular control over dependencies.
  • Improved Compatibility: Can reduce dependency conflicts.

Proposed Changes:

  1. Create a dedicated pymoo/visualization module/subpackage: Move all plotting-related code into this separate module/subpackage.
  2. Define a visualization extra: In setup.py, define a visualization extra that includes matplotlib as a dependency.
  3. Ensure no core modules import from pymoo/visualization: Verify that the core optimization modules do not import anything from the plotting module.
  4. Documentation Update: Update the documentation to reflect the optional plotting extra and guide users on how to install it.

Example Usage (with the proposed change):

  • Install with plotting:

    pip install pymoo[plotting]
  • Install without plotting:

    pip install pymoo

Context:

My specific use case involves embedding pymoo into a FastAPI backend. In this context, generating plots is completely irrelevant, and the inclusion of matplotlib is a significant overhead.

I believe this change would make pymoo more versatile and efficient for a broader range of applications.

Would the pymoo maintainers consider implementing this feature?

Thank you for your time and consideration.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions