Skip to content

import libemg now unconditionally loads torch + tslearn (PyQt6 conflicts) #139

@Michiboi29

Description

@Michiboi29

Since #130 (2c21236), libemg/init.py ends with from libemg import _discrete_models, whose submodules import torch and tslearn at module level.
As a result, any import libemg, even just from libemg.data_handler import OnlineDataHandler, now loads torch.

Reproduction
pip install libemg
python -c "from libemg.data_handler import OnlineDataHandler; import sys; print('torch' in sys.modules)"

True (was False pre-#130)

Results

  • torch and tslearn are now hard install deps for users who never touch discrete models.
  • import libemg start-up time grew significantly (torch init).
  • On Windows, any consumer that imports a Qt binding before libemg now hits torch's well-known DLL conflict (Qt's Qt*\bin shadowing the runtimes
    c10.dll needs → WinError 1114). Pre-Latest #130 consumers were insulated because libemg didn't load torch.

Possible fix :

  • Drop the from libemg import _discrete_models line — let users opt in with from libemg._discrete_models import ….

  • Lazy-import torch/tslearn inside the discrete-model classes rather than at module top.

  • Move torch / tslearn to an optional extra (libemg[discrete]).

    Happy to PR whichever direction maintainers prefer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions