Thierry Jean
09/02/2025, 3:35 PMnumpy and pandas as required dependencies? AFAIK, they are currently there for backwards compatibility with plugin autoloading. Currently, this is a barrier to adoption in my case where I want to use Hamilton's lightweight features.>
Older pandas and numpy features exist on some modules of the "main code path". The import statements could be moved inside the relevant functions / classes to make them lazy
Is there a way to package the project such that pip install sf-hamilton[core] doesn't include those?Stefan Krawczyk
09/02/2025, 6:16 PMThierry Jean
09/02/2025, 6:18 PMsf-hamilton as an optional dependency in dltThierry Jean
09/02/2025, 6:21 PMpip install sf-hamilton to have pandas installed is leaky dependency management. Removing pandas wouldn't be a breaking changes.
The tricky situation is that Hamilton does autoload_plugin=True by default. Therefore, removing pandas becomes a breaking change in that case.Thierry Jean
09/02/2025, 6:35 PMhamilton.base.PandasDataFrameResult
• hamilton.base.StrictIndexTypePandasDataFrameResult
• hamilton.base.NumpyMatrixResult
• hamilton.base.SimplePythonDataFrameGraphAdapter
• hamilton.base.SimplePythonGraphAdapter
• hamilton.base.DefaultAdapter
They seem to be the main / only culprit.
IMHO, we should setup deprecation warnings and have a clear plan to:
1. remove pandas, numpy and networkx (in visualization extra, but is unused) dependencies
2. disable plugin autoloading by default
Otherwise, the only solution would be forking the repo and distributing sf-hamilton-core, which seems less than ideal.Stefan Krawczyk
09/02/2025, 6:57 PMnumpy and pandas isn't installed.
Then we can figure something out with respect to the package -- for version < 2. we could do something like sf-hamilton-core and then have sf-hamilton depend on it...Thierry Jean
09/02/2025, 7:00 PM.py file that:
• import hamilton registry
• disable autoload
• patches the hamilton.base module with a version that doesn't import pandas and numpy at the top-level.
This could exist within the apache/hamilton monorepo.
Should I spend some time opening a draft PR ?Stefan Krawczyk
09/02/2025, 8:12 PMThierry Jean
09/02/2025, 8:24 PMapache/hamilton, you create hamilton-core/
• it has its own pyproject.toml that doesn't have pandas and numpy as deps
• pyproject.toml with a directive to include hamilton/ in its build
◦ a user that pip install sf-hamilton-core will get all of the hamilton source code, but is not depending on sf-hamilton explicitly
• hamilton-core/__init__.py and its module hold no implementation, they simply import from the localized hamilton source code
• hamilton-core will only reimplement the hamilton.base module, by moving the pandas and numpy imports to a lazy location
• hamilton-core will need to add a test to check that all sf-hamilton objects can be imported
• Going one-step further, the hamilton-core/pyproject.toml could be written in such a way that it produces a Python library with the name hamilton, making it a drop-in replacement.
User experience:
• pip uninstall sf-hamilton
• pip install sf-hamilton-core
• code should just work, but without the deps
• pip list will show sf-hamilton-core instead of sf-hamiltonThierry Jean
09/02/2025, 8:25 PMStefan Krawczyk
09/02/2025, 9:48 PMThierry Jean
09/03/2025, 1:41 AMsetup.py from the original pyproject.toml and remove the pandas and numpy deps
• pip install sf-hamilton-core produces a drop-in replacement available via import hamilton
• this new module has extension autoloading disabled by default and doesn't install pandas and numpy
• this new module passes all tests (with pandas and numpy installed)Thierry Jean
09/03/2025, 1:42 AM