-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: make NumPy, pandas, and Arrow deps optional #152
Changes from 5 commits
296fd66
4c8f7ce
e84c65c
9e3e466
a39720b
c156061
f578721
6475e26
9e80c6a
5f88d12
6c7f9f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you do this in a separate file instead of, say, If it's in a separate file, I can't see how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not try puting it in the test_core, the reason I put it in the new file becuase 1) some other files, such as _discretize.py also dependes on numpy 2) It is testing how the dependency impact the IbisML loading. I named it |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sys | ||
from importlib import import_module, reload | ||
from unittest import mock | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize("optional_dep", ["pandas", "numpy", "pyarrow"]) | ||
def test_optional_dependencies(optional_dep, caplog): | ||
jitingxu1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with mock.patch.dict(sys.modules): | ||
sys.modules[optional_dep] = None | ||
if "ibis_ml" in sys.modules: | ||
reload(sys.modules["ibis_ml"]) | ||
else: | ||
import_module("ibis_ml") | ||
|
||
assert "ibis_ml" in sys.modules | ||
jitingxu1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def test_import(): | ||
try: | ||
import_module("ibis_ml") | ||
except AttributeError: | ||
raise ImportError("cannot import IbisML") from None | ||
assert "ibis_ml" in sys.modules | ||
jitingxu1 marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes for PyArrow are not necessary, as it is a required dependency. Can you undo them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not find it is required dependency in Ibis and IbisML
https://github.com/ibis-project/ibis/blob/main/pyproject.toml#L49 was marked as optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, makes sense; I forgot about ibis-project/ibis#9552.
Guess this is fine then, to avoid having to maintain PyArrow bounds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a bad idea to not explicitly include dependencies that you are explicitly importing. You shouldn't really ever depend on another project to have specific dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean we should explicitly include the dependency in IbisML. It is convenient users successfully imported IbisML, but when they use it, they'll get ModuleNotFound error, have to install it.
@deepyaman do you have any comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't explicitly require pandas/NumPy; we don't need to include those dependencies, unless a user is using a backend/ML framework that requires it. Those are specified in extras.
For PyArrow... trying to think, can you reasonably use IbisML without PyArrow? I took some looks at the linked PR in Ibis, and it seems there was some use case from people using Ibis internally in their product that could not need the PyArrow dependency. Is that also possible with IbisML? I wasn't completely sure...
In this case, I'm personally OK with leaving it as is, since IbisML isn't just getting a transitive dependency from Ibis—it completely relies on Ibis under the hood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To unblock the release, let's keep it as it is now. We could change this later if we have new findings.