ezmsg-org / ezmsg

Pure-Python DAG-based high-performance SHM-backed pub-sub and multi-processing pattern
https://ezmsg.readthedocs.io/en/latest/
MIT License
16 stars 6 forks source link

numpy optional for AxisArray #160

Open cboulay opened 1 day ago

cboulay commented 1 day ago

I guess this rarely comes up because almost everything using ezmsg also uses numpy, but not everything! (ezmsg-zmq for example) This should be a quick fix. I'll go straight to main.

griffinmilsap commented 21 hours ago

@cboulay I don't know that numpy is actually a dependency of this package. I've always treated it as an optional dependency and a testing dependency because our tests rely on it and AxisArray depends on it, but we don't require users to use AxisArray if they don't want.

I take quite a bit of pride in stating that ezmsg core has no dependencies (typing-extensions doesn't count IMO) and would like to keep it that way :P

cboulay commented 20 hours ago

OK. It seems sloppy to have numpy a dependency in the package code but not included in the dependencies list. Maybe we can do something like the following to let the user know this is intentional:

# in ezmsg.util.messages.axisarray
try:
    import numpy as np
except ModuleImportError:
    print("Use of AxisArray requires ezmsg to be installed with `pip install ezmsg[AxisArray]`")

And we change the pyproject.toml to have the optional dependency group for AxisArray which includes numpy.

Would that work better?

cboulay commented 20 hours ago

Another option would be to move AxisArray to ezmsg-sigproc.

griffinmilsap commented 20 hours ago

Im happy to have the try-except block in there for now. I predict that we will have a lot of activity in AxisArray for the foreseeable future, but the rest of core is pretty stable at the moment. Moving AxisArray to sigproc had crossed my mind but I don't like having to bring in the whole sigproc library for a message definition. For now let's keep it in core with the try except block around the numpy import, but we may consider making AxisArray it's own little package if it gets enough features or possibly including it in a ezmsg-std-msgs repo of common message types (which is what ROS does)