| 1 | name: Python |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: |
| 6 | - main |
| 7 | pull_request: |
| 8 | paths: |
| 9 | - python/** |
| 10 | - .github/workflows/python.yml |
| 11 | |
| 12 | concurrency: |
| 13 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 14 | cancel-in-progress: true |
| 15 | |
| 16 | jobs: |
| 17 | lint: |
| 18 | name: "Lint" |
| 19 | timeout-minutes: 30 |
| 20 | runs-on: "ubuntu-22.04" |
| 21 | defaults: |
| 22 | run: |
| 23 | shell: bash |
| 24 | working-directory: python |
| 25 | steps: |
| 26 | - uses: actions/checkout@v4 |
| 27 | with: |
| 28 | fetch-depth: 0 |
| 29 | lfs: true |
| 30 | - name: Set up Python |
| 31 | uses: actions/setup-python@v5 |
| 32 | with: |
| 33 | python-version: "3.11" |
| 34 | - name: Install ruff |
| 35 | run: | |
| 36 | pip install ruff==0.5.4 |
| 37 | - name: Format check |
| 38 | run: ruff format --check . |
| 39 | - name: Lint |
| 40 | run: ruff check . |
| 41 | doctest: |
| 42 | name: "Doctest" |
| 43 | timeout-minutes: 30 |
| 44 | runs-on: "ubuntu-22.04" |
| 45 | defaults: |
| 46 | run: |
| 47 | shell: bash |
| 48 | working-directory: python |
| 49 | steps: |
| 50 | - uses: actions/checkout@v4 |
| 51 | with: |
| 52 | fetch-depth: 0 |
| 53 | lfs: true |
| 54 | - name: Set up Python |
| 55 | uses: actions/setup-python@v5 |
| 56 | with: |
| 57 | python-version: "3.11" |
| 58 | cache: "pip" |
| 59 | - name: Install protobuf |
| 60 | run: | |
| 61 | sudo apt update |
| 62 | sudo apt install -y protobuf-compiler |
| 63 | - uses: Swatinem/rust-cache@v2 |
| 64 | with: |
| 65 | workspaces: python |
| 66 | - name: Install |
| 67 | run: | |
| 68 | pip install --extra-index-url https://pypi.fury.io/lancedb/ -e .[tests,dev,embeddings] |
| 69 | pip install tantivy |
| 70 | pip install mlx |
| 71 | - name: Doctest |
| 72 | run: pytest --doctest-modules python/lancedb |
| 73 | linux: |
| 74 | name: "Linux: python-3.${{ matrix.python-minor-version }}" |
| 75 | timeout-minutes: 30 |
| 76 | strategy: |
| 77 | matrix: |
| 78 | python-minor-version: ["9", "11"] |
| 79 | runs-on: "ubuntu-22.04" |
| 80 | defaults: |
| 81 | run: |
| 82 | shell: bash |
| 83 | working-directory: python |
| 84 | steps: |
| 85 | - uses: actions/checkout@v4 |
| 86 | with: |
| 87 | fetch-depth: 0 |
| 88 | lfs: true |
| 89 | - name: Install protobuf |
| 90 | run: | |
| 91 | sudo apt update |
| 92 | sudo apt install -y protobuf-compiler |
| 93 | - name: Set up Python |
| 94 | uses: actions/setup-python@v5 |
| 95 | with: |
| 96 | python-version: 3.${{ matrix.python-minor-version }} |
| 97 | - uses: Swatinem/rust-cache@v2 |
| 98 | with: |
| 99 | workspaces: python |
| 100 | - uses: ./.github/workflows/build_linux_wheel |
| 101 | - uses: ./.github/workflows/run_tests |
| 102 | with: |
| 103 | integration: true |
| 104 | # Make sure wheels are not included in the Rust cache |
| 105 | - name: Delete wheels |
| 106 | run: rm -rf target/wheels |
| 107 | platform: |
| 108 | name: "Mac: ${{ matrix.config.name }}" |
| 109 | timeout-minutes: 30 |
| 110 | strategy: |
| 111 | matrix: |
| 112 | config: |
| 113 | - name: x86 |
| 114 | runner: macos-13 |
| 115 | - name: Arm |
| 116 | runner: macos-14 |
| 117 | runs-on: "${{ matrix.config.runner }}" |
| 118 | defaults: |
| 119 | run: |
| 120 | shell: bash |
| 121 | working-directory: python |
| 122 | steps: |
| 123 | - uses: actions/checkout@v4 |
| 124 | with: |
| 125 | fetch-depth: 0 |
| 126 | lfs: true |
| 127 | - name: Set up Python |
| 128 | uses: actions/setup-python@v5 |
| 129 | with: |
| 130 | python-version: "3.11" |
| 131 | - uses: Swatinem/rust-cache@v2 |
| 132 | with: |
| 133 | workspaces: python |
| 134 | - uses: ./.github/workflows/build_mac_wheel |
| 135 | - uses: ./.github/workflows/run_tests |
| 136 | # Make sure wheels are not included in the Rust cache |
| 137 | - name: Delete wheels |
| 138 | run: rm -rf target/wheels |
| 139 | windows: |
| 140 | name: "Windows: ${{ matrix.config.name }}" |
| 141 | timeout-minutes: 30 |
| 142 | strategy: |
| 143 | matrix: |
| 144 | config: |
| 145 | - name: x86 |
| 146 | runner: windows-latest |
| 147 | runs-on: "${{ matrix.config.runner }}" |
| 148 | defaults: |
| 149 | run: |
| 150 | shell: bash |
| 151 | working-directory: python |
| 152 | steps: |
| 153 | - uses: actions/checkout@v4 |
| 154 | with: |
| 155 | fetch-depth: 0 |
| 156 | lfs: true |
| 157 | - name: Set up Python |
| 158 | uses: actions/setup-python@v5 |
| 159 | with: |
| 160 | python-version: "3.11" |
| 161 | - uses: Swatinem/rust-cache@v2 |
| 162 | with: |
| 163 | workspaces: python |
| 164 | - uses: ./.github/workflows/build_windows_wheel |
| 165 | - uses: ./.github/workflows/run_tests |
| 166 | # Make sure wheels are not included in the Rust cache |
| 167 | - name: Delete wheels |
| 168 | run: rm -rf target/wheels |
| 169 | pydantic1x: |
| 170 | timeout-minutes: 30 |
| 171 | runs-on: "ubuntu-22.04" |
| 172 | defaults: |
| 173 | run: |
| 174 | shell: bash |
| 175 | working-directory: python |
| 176 | steps: |
| 177 | - uses: actions/checkout@v4 |
| 178 | with: |
| 179 | fetch-depth: 0 |
| 180 | lfs: true |
| 181 | - name: Install dependencies |
| 182 | run: | |
| 183 | sudo apt update |
| 184 | sudo apt install -y protobuf-compiler |
| 185 | - name: Set up Python |
| 186 | uses: actions/setup-python@v5 |
| 187 | with: |
| 188 | python-version: 3.9 |
| 189 | - name: Install lancedb |
| 190 | run: | |
| 191 | pip install "pydantic<2" |
| 192 | pip install --extra-index-url https://pypi.fury.io/lancedb/ -e .[tests] |
| 193 | pip install tantivy |
| 194 | - name: Run tests |
| 195 | run: pytest -m "not slow and not s3_test" -x -v --durations=30 python/tests |