Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PyTorch dependency and use it for item-item k-NN #373

Merged
merged 21 commits into from
May 7, 2024
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
if: runner.os == 'Linux'
env:
NUMBA_DISABLE_JIT: 1
PYTORCH_JIT: 0
run: |
python -m pytest --cov=lenskit --cov-append -m 'not slow' --log-file=test-nojit.log

Expand Down
22 changes: 18 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,37 @@
# SPDX-License-Identifier: MIT

import logging
from pytest import fixture
import os
import time
import warnings

from seedbank import initialize, numpy_rng

from seedbank import numpy_rng, initialize
from pytest import fixture

logging.getLogger("numba").setLevel(logging.INFO)

_log = logging.getLogger("lenskit.tests")
RNG_SEED = 42
if "LK_TEST_FREE_RNG" in os.environ:
warnings.warn("using nondeterministic RNG initialization")
RNG_SEED = None


@fixture
def rng():
return numpy_rng(42)
if RNG_SEED is None:
return numpy_rng(os.urandom(4))
else:
return numpy_rng(RNG_SEED)


@fixture(autouse=True)
def init_rng(request):
initialize(42)
if RNG_SEED is None:
initialize(os.urandom(4))
else:
initialize(RNG_SEED)


@fixture(autouse=True)
Expand Down
3 changes: 3 additions & 0 deletions envs/lenskit-py3.10-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#
channels:
- conda-forge
- pytorch
- nodefaults
dependencies:
- python=3.10
- binpickle>=0.3.2
Expand All @@ -29,6 +31,7 @@ dependencies:
- pytest-doctestplus==1.*
- pytest==7.*
- python-build==1
- pytorch==2.*
- ruff>=0.2
- scikit-learn>=1.1
- scipy>=1.9.0
Expand Down
3 changes: 3 additions & 0 deletions envs/lenskit-py3.10-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#
channels:
- conda-forge
- pytorch
- nodefaults
dependencies:
- python=3.10
- binpickle>=0.3.2
Expand All @@ -34,6 +36,7 @@ dependencies:
- pytest-doctestplus==1.*
- pytest==7.*
- python-build==1
- pytorch==2.*
- ruff>=0.2
- scikit-learn>=1.1
- scipy>=1.9.0
Expand Down
3 changes: 3 additions & 0 deletions envs/lenskit-py3.10-doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#
channels:
- conda-forge
- pytorch
- nodefaults
dependencies:
- python=3.10
- binpickle>=0.3.2
Expand All @@ -19,6 +21,7 @@ dependencies:
- numba<0.59,>=0.56
- numpy>=1.23
- pandas<3,>=1.5
- pytorch==2.*
- scipy>=1.9.0
- seedbank>=0.1.0
- sphinx>=4.2
Expand Down
3 changes: 3 additions & 0 deletions envs/lenskit-py3.10-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#
channels:
- conda-forge
- pytorch
- nodefaults
dependencies:
- python=3.10
- binpickle>=0.3.2
Expand All @@ -23,6 +25,7 @@ dependencies:
- pytest-cov>=2.12
- pytest-doctestplus==1.*
- pytest==7.*
- pytorch==2.*
- scipy>=1.9.0
- seedbank>=0.1.0
- tbb
Expand Down
3 changes: 3 additions & 0 deletions envs/lenskit-py3.11-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#
channels:
- conda-forge
- pytorch
- nodefaults
dependencies:
- python=3.11
- binpickle>=0.3.2
Expand All @@ -29,6 +31,7 @@ dependencies:
- pytest-doctestplus==1.*
- pytest==7.*
- python-build==1
- pytorch==2.*
- ruff>=0.2
- scikit-learn>=1.1
- scipy>=1.9.0
Expand Down
3 changes: 3 additions & 0 deletions envs/lenskit-py3.11-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#
channels:
- conda-forge
- pytorch
- nodefaults
dependencies:
- python=3.11
- binpickle>=0.3.2
Expand All @@ -34,6 +36,7 @@ dependencies:
- pytest-doctestplus==1.*
- pytest==7.*
- python-build==1
- pytorch==2.*
- ruff>=0.2
- scikit-learn>=1.1
- scipy>=1.9.0
Expand Down
3 changes: 3 additions & 0 deletions envs/lenskit-py3.11-doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#
channels:
- conda-forge
- pytorch
- nodefaults
dependencies:
- python=3.11
- binpickle>=0.3.2
Expand All @@ -19,6 +21,7 @@ dependencies:
- numba<0.59,>=0.56
- numpy>=1.23
- pandas<3,>=1.5
- pytorch==2.*
- scipy>=1.9.0
- seedbank>=0.1.0
- sphinx>=4.2
Expand Down
3 changes: 3 additions & 0 deletions envs/lenskit-py3.11-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#
channels:
- conda-forge
- pytorch
- nodefaults
dependencies:
- python=3.11
- binpickle>=0.3.2
Expand All @@ -23,6 +25,7 @@ dependencies:
- pytest-cov>=2.12
- pytest-doctestplus==1.*
- pytest==7.*
- pytorch==2.*
- scipy>=1.9.0
- seedbank>=0.1.0
- tbb
Expand Down
2 changes: 1 addition & 1 deletion lenskit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
__version__ = version("lenskit")
except PackageNotFoundError:
# package is not installed
pass
__version__ = "UNKNOWN"


class DataWarning(UserWarning):
Expand Down
Loading
Loading