diff --git a/.github/workflows/pythonbuild.yml b/.github/workflows/pythonbuild.yml index f56caffc0d..dfa83fca20 100644 --- a/.github/workflows/pythonbuild.yml +++ b/.github/workflows/pythonbuild.yml @@ -122,6 +122,13 @@ jobs: os: [ubuntu-latest] python-version: ${{fromJson(needs.detect-python-versions.outputs.python-versions)}} pandas: ["pandas<2.0.0", "pandas>=2.0.0"] + numpy: ["numpy<2.0.0", "numpy>=2.0.0"] + exclude: + - numpy: "numpy>=2.0.0" + pandas: "pandas<2.0.0" + - numpy: "numpy<2.0.0" + pandas: "pandas>=2.0.0" + steps: - uses: actions/checkout@v4 - name: 'Clear action cache' @@ -141,7 +148,7 @@ jobs: run: | pip install uv make setup-global-uv - uv pip install --system --force-reinstall "${{ matrix.pandas }}" + uv pip install --system --force-reinstall "${{ matrix.pandas }}" "${{ matrix.numpy }}" uv pip freeze - name: Test with coverage run: | @@ -419,6 +426,10 @@ jobs: if [ -f dev-requirements.in ]; then uv pip install --system -r dev-requirements.in; fi # TODO: move to protobuf>=5. Github issue: https://github.com/flyteorg/flyte/issues/5448 uv pip install --system -U $GITHUB_WORKSPACE "protobuf<5" + # TODO: remove this when numpy v2 in onnx has been resolved + if [[ ${{ matrix.plugin-names }} == *"onnx"* || ${{ matrix.plugin-names }} == "flytekit-sqlalchemy" ]]; then + uv pip install --system "numpy<2.0.0" + fi uv pip freeze - name: Test with coverage run: | diff --git a/flytekit/types/numpy/__init__.py b/flytekit/types/numpy/__init__.py index ec20e87970..bf690d3ddb 100644 --- a/flytekit/types/numpy/__init__.py +++ b/flytekit/types/numpy/__init__.py @@ -1 +1,15 @@ -from .ndarray import NumpyArrayTransformer +from flytekit.loggers import logger + +try: + # isolate the exception to the numpy import + import numpy + + _numpy_installed = True +except ImportError: + _numpy_installed = False + + +if _numpy_installed: + from .ndarray import NumpyArrayTransformer +else: + logger.info("We won't register NumpyArrayTransformer because numpy is not installed.") diff --git a/pyproject.toml b/pyproject.toml index 74a41ae422..5aece34595 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,6 @@ dependencies = [ "marshmallow-enum", "marshmallow-jsonschema>=0.12.0", "mashumaro>=3.11", - "numpy<2", "protobuf!=4.25.0", "pyarrow", "pygments",