Skip to content

Commit c19ddd1

Browse files
authored
floret: Add version 0.10.5 (#2694)
1 parent d13b54e commit c19ddd1

4 files changed

Lines changed: 211 additions & 0 deletions

File tree

‎.github/workflows/build-floret.yml‎

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# SPDX-FileCopyrightText: 2026 The RISE Project
2+
# SPDX-License-Identifier: MIT
3+
---
4+
# This workflow is based on: https://github.com/explosion/floret/blob/v0.10.5/.github/workflows/tests.yml
5+
name: Build floret wheels (riscv64)
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: 'Version glob to (re)build; empty builds every version of docs/packages/floret.yaml not released yet'
12+
required: false
13+
default: ''
14+
pull_request:
15+
branches: [main]
16+
paths:
17+
- '.github/workflows/build-floret.yml'
18+
- 'docs/packages/floret.yaml'
19+
- 'patches/floret/**'
20+
push:
21+
branches: [main]
22+
paths:
23+
- '.github/workflows/build-floret.yml'
24+
- 'docs/packages/floret.yaml'
25+
- 'patches/floret/**'
26+
27+
concurrency:
28+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
29+
cancel-in-progress: true
30+
31+
permissions:
32+
contents: read # to fetch code (actions/checkout)
33+
34+
env:
35+
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
36+
37+
jobs:
38+
setup:
39+
uses: $/.github/workflows/_setup.yml
40+
with:
41+
package: floret
42+
version: ${{ inputs.version }}
43+
44+
build_wheels:
45+
needs: [setup]
46+
if: needs.setup.outputs.versions != '[]'
47+
name: Build floret ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64
48+
runs-on: ubuntu-24.04-riscv
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
version: ${{ fromJSON(needs.setup.outputs.versions) }}
53+
# No cp314t: upstream ships no free-threaded wheel and its pybind11 module does not declare GIL-free support.
54+
python:
55+
- "cp312"
56+
- "cp313"
57+
- "cp314"
58+
59+
env:
60+
FLORET_VERSION: ${{ matrix.version }}
61+
62+
steps:
63+
- name: Checkout floret ${{ env.FLORET_VERSION }}
64+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
65+
with:
66+
repository: explosion/floret
67+
ref: v${{ env.FLORET_VERSION }}
68+
persist-credentials: false
69+
70+
- name: Checkout python-wheels
71+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
72+
with:
73+
path: python-wheels
74+
persist-credentials: false
75+
76+
- name: Patch floret source
77+
run: git apply python-wheels/patches/floret/${{ env.FLORET_VERSION }}/00*.patch
78+
79+
- name: Build wheels
80+
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
81+
with:
82+
output-dir: wheelhouse/
83+
only: ${{ matrix.python }}-manylinux_riscv64
84+
env:
85+
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
86+
CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/
87+
CIBW_TEST_REQUIRES: pytest
88+
# tests/runtests.py ignores the unittest result, so run its gen_unit_tests() suite with an exit code.
89+
CIBW_TEST_COMMAND: >-
90+
python -c "import floret_pybind; assert floret_pybind.__file__.endswith('.so'), floret_pybind.__file__" &&
91+
python -m pytest --pyargs floret -Werror &&
92+
python -c "import unittest, sys; from floret.tests import gen_unit_tests; r = unittest.TextTestRunner(verbosity=2).run(unittest.TestLoader().loadTestsFromTestCase(gen_unit_tests())); sys.exit(0 if r.wasSuccessful() else 1)"
93+
94+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
95+
with:
96+
name: floret-${{ matrix.version }}-${{ matrix.python }}-manylinux_riscv64
97+
path: wheelhouse/*.whl
98+
if-no-files-found: error
99+
100+
publish:
101+
name: Publish floret ${{ matrix.version }}
102+
needs: [setup, build_wheels]
103+
if: needs.setup.outputs.versions != '[]'
104+
strategy:
105+
fail-fast: false
106+
matrix:
107+
version: ${{ fromJSON(needs.setup.outputs.versions) }}
108+
permissions:
109+
contents: write
110+
pull-requests: write
111+
uses: $/.github/workflows/_publish-wheel.yml
112+
secrets:
113+
app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }}
114+
with:
115+
artifact-pattern: floret-${{ matrix.version }}-*-manylinux_riscv64

‎docs/packages/floret.yaml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package-name: floret
2+
source-code: https://github.com/explosion/floret
3+
license: MIT
4+
versions:
5+
- version: 0.10.5
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Ludovic Henry <git@ludovic.dev>
3+
Date: Sun, 4 Oct 2026 00:00:00 +0000
4+
Subject: [PATCH] args: fix missing <cstdint> include for uint64_t
5+
6+
Upstream-Status: To upstream [not yet submitted; python-wheels does not open issues/PRs on third-party repos]
7+
8+
args.cc uses `uint64_t` in `getAutotuneModelSize()` without including
9+
`<cstdint>`, relying on it being pulled in transitively by another
10+
header. GCC 13 stopped exposing it that way
11+
(https://gcc.gnu.org/gcc-13/porting_to.html#header-dep-changes), so the
12+
build fails with any GCC >= 13, including the manylinux_riscv64 image's,
13+
and reproduces on x86_64 with Ubuntu 24.04's GCC 13.3:
14+
15+
src/args.cc:512:3: error: 'uint64_t' was not declared in this scope
16+
17+
floret is a fork of fastText, which fixed the same line in
18+
facebookresearch/fastText@6c2204ba66776b700095ff73e3e599a908ffd9c3
19+
("fix compile error with gcc13 #1281 (#1340)"); floret has not picked
20+
it up, including on its main branch.
21+
22+
Signed-off-by: Ludovic Henry <git@ludovic.dev>
23+
---
24+
src/args.cc | 1 +
25+
1 file changed, 1 insertion(+)
26+
27+
diff --git a/src/args.cc b/src/args.cc
28+
index a8975e8..8dd2232 100644
29+
--- a/src/args.cc
30+
+++ b/src/args.cc
31+
@@ -9,6 +9,7 @@
32+
#include "args.h"
33+
34+
#include <stdlib.h>
35+
+#include <cstdint>
36+
37+
#include <iostream>
38+
#include <stdexcept>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Ludovic Henry <git@ludovic.dev>
3+
Date: Sun, 4 Oct 2026 00:00:00 +0000
4+
Subject: [PATCH] floret: fix numpy 2.x `copy=False` compatibility
5+
6+
Upstream-Status: To upstream [not yet submitted; python-wheels does not open issues/PRs on third-party repos]
7+
8+
numpy 2.0 made `np.array(obj, copy=False)` raise `ValueError: Unable to
9+
avoid copy while creating an array as requested` whenever a copy is
10+
needed, which `_floret.predict`, `_Meter.scores` and
11+
`_Meter.precision_recall_curve` hit on every call since they convert
12+
Python lists. This is not riscv64-specific: it fails on any platform
13+
with numpy >= 2.0, which is the only numpy our registry serves for
14+
riscv64 and the only one available for cp313+. Switching to
15+
`np.asarray`, numpy's documented migration fix, keeps numpy 1.x
16+
behaviour and fixes numpy 2.x.
17+
18+
Signed-off-by: Ludovic Henry <git@ludovic.dev>
19+
---
20+
python/floret_module/floret/floret.py | 6 +++---
21+
1 file changed, 3 insertions(+), 3 deletions(-)
22+
23+
diff --git a/python/floret_module/floret/floret.py b/python/floret_module/floret/floret.py
24+
index 6212ab6..9abcc22 100644
25+
--- a/python/floret_module/floret/floret.py
26+
+++ b/python/floret_module/floret/floret.py
27+
@@ -40,7 +40,7 @@ class _Meter(object):
28+
else:
29+
y_scores, y_true = ([], ())
30+
31+
- return np.array(y_scores, copy=False), np.array(y_true, copy=False)
32+
+ return np.asarray(y_scores), np.asarray(y_true)
33+
34+
def precision_recall_curve(self, label=None):
35+
"""Return precision/recall curve"""
36+
@@ -55,7 +55,7 @@ class _Meter(object):
37+
else:
38+
precision, recall = ([], ())
39+
40+
- return np.array(precision, copy=False), np.array(recall, copy=False)
41+
+ return np.asarray(precision), np.asarray(recall)
42+
43+
def precision_at_recall(self, recall, label=None):
44+
"""Return precision for a given recall"""
45+
@@ -227,7 +227,7 @@ class _floret(object):
46+
else:
47+
probs, labels = ([], ())
48+
49+
- return labels, np.array(probs, copy=False)
50+
+ return labels, np.asarray(probs)
51+
52+
def get_input_matrix(self):
53+
"""

0 commit comments

Comments
 (0)