Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,13 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.7", "3.11"]
exclude:
- os: macos-latest
python-version: "3.7"
- os: windows-latest
python-version: "3.7"
os: [ubuntu-24.04, macos-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- repo: "https://github.com/psf/black"
rev: "22.1.0"
rev: "24.10.0"
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: "4.0.1"
- repo: https://github.com/PyCQA/flake8
rev: "7.1.1"
hooks:
- id: flake8
types: [file, python]
Expand Down
28 changes: 13 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
FROM ubuntu:16.04
FROM debian:trixie-slim

RUN apt-get update
RUN apt-get install -y libxml2 libxslt-dev wget bzip2 gcc
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-pip \
python3-dev \
gcc \
libgomp1 \
libxml2 \
libxslt-dev \
&& rm -rf /var/lib/apt/lists/*

RUN echo 'export PATH=/opt/conda/bin:$PATH' > /etc/profile.d/conda.sh && \
wget --quiet https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh

ENV PATH /opt/conda/bin:$PATH

RUN conda install pytest jupyter scikit-learn

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONDONTWRITEBYTECODE=1

ADD . /home/lightfm/
WORKDIR /home/
WORKDIR /home/lightfm/

RUN cd lightfm && pip install -e .
RUN pip install --break-system-packages -e .
20 changes: 10 additions & 10 deletions lightfm/_lightfm_fast.pyx.template
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ cdef struct Pair:
flt val


cdef int reverse_pair_compare(const_void *a, const_void *b) nogil:
cdef int reverse_pair_compare(const_void *a, const_void *b) noexcept nogil:

cdef flt diff

Expand All @@ -122,7 +122,7 @@ cdef int reverse_pair_compare(const_void *a, const_void *b) nogil:
return -1


cdef int int_compare(const_void *a, const_void *b) nogil:
cdef int int_compare(const_void *a, const_void *b) noexcept nogil:

if deref(<int*>a) - deref(<int*>b) > 0:
return 1
Expand All @@ -132,7 +132,7 @@ cdef int int_compare(const_void *a, const_void *b) nogil:
return 0


cdef int flt_compare(const_void *a, const_void *b) nogil:
cdef int flt_compare(const_void *a, const_void *b) noexcept nogil:

if deref(<flt*>a) - deref(<flt*>b) > 0:
return 1
Expand Down Expand Up @@ -165,15 +165,15 @@ cdef class CSRMatrix:
self.rows, self.cols = csr_matrix.shape
self.nnz = len(self.data)

cdef int get_row_start(self, int row) nogil:
cdef int get_row_start(self, int row) noexcept nogil:
"""
Return the pointer to the start of the
data for row.
"""

return self.indptr[row]

cdef int get_row_end(self, int row) nogil:
cdef int get_row_end(self, int row) noexcept nogil:
"""
Return the pointer to the end of the
data for row.
Expand Down Expand Up @@ -290,7 +290,7 @@ cdef inline void compute_representation(CSRMatrix features,
FastLightFM lightfm,
int row_id,
double scale,
flt *representation) nogil:
flt *representation) noexcept nogil:
"""
Compute latent representation for row_id.
The last element of the representation is the bias.
Expand Down Expand Up @@ -460,7 +460,7 @@ cdef inline void update(double loss,
flt *it_repr,
FastLightFM lightfm,
double item_alpha,
double user_alpha) nogil:
double user_alpha) noexcept nogil:
"""
Apply the gradient step.
"""
Expand Down Expand Up @@ -545,7 +545,7 @@ cdef void warp_update(double loss,
flt *neg_it_repr,
FastLightFM lightfm,
double item_alpha,
double user_alpha) nogil:
double user_alpha) noexcept nogil:
"""
Apply the gradient step.
"""
Expand Down Expand Up @@ -651,7 +651,7 @@ cdef void warp_update(double loss,

cdef void regularize(FastLightFM lightfm,
double item_alpha,
double user_alpha) nogil:
double user_alpha) noexcept nogil:
"""
Apply accumulated L2 regularization to all features.
"""
Expand All @@ -677,7 +677,7 @@ cdef void regularize(FastLightFM lightfm,

cdef void locked_regularize(FastLightFM lightfm,
double item_alpha,
double user_alpha) nogil:
double user_alpha) noexcept nogil:
"""
Apply accumulated L2 regularization to all features. Acquire a lock
to prevent multiple threads from performing this operation.
Expand Down
Loading