Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand All @@ -25,7 +25,7 @@ jobs:

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .venv
key: venv-lint-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
Expand All @@ -43,13 +43,13 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
python-version: [ "3.9", "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -58,7 +58,7 @@ jobs:

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .venv
key: venv-test-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: 2

build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.12"
jobs:
pre_build:
- cp -r examples docs/source/
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `model_from_config` function ([#214](https://github.com/MobileTeleSystems/RecTools/pull/214))
- `get_cat_features` method to `SparseFeatures` ([#221](https://github.com/MobileTeleSystems/RecTools/pull/221))

### Removed
- Python 3.8 support ([#222](https://github.com/MobileTeleSystems/RecTools/pull/222))


## [0.8.0] - 28.08.2024

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Pull Request Process
#. Create a virtual environment and install dependencies including all
extras and development dependencies.

#. Make sure you have ``python>=3.8`` and ``poetry>=1.5.0`` installed
#. Make sure you have ``python>=3.9`` and ``poetry>=1.5.0`` installed
#. Deactivate any active virtual environments. Deactivate conda ``base``
environment if applicable
#. Run ``make install`` command which will create a virtual env and
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Security Policy

**Supported Python versions**

3.8 or above
3.9 or above

**Product development security recommendations**

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8
FROM python:3.9

WORKDIR /usr/app

Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Install from PyPi using pip

$ pip install rectools

RecTools is compatible with all operating systems and with Python 3.8+.
RecTools is compatible with all operating systems and with Python 3.9+.
The default version doesn't contain all the dependencies. Optional dependencies are the following:

lightfm: adds wrapper for LightFM model,
Expand Down
2,829 changes: 1,507 additions & 1,322 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ keywords = [
classifiers = [
"Development Status :: 3 - Alpha",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -53,17 +52,13 @@ packages = [


[tool.poetry.dependencies]
python = ">=3.8.1, <3.13"
python = ">=3.9, <3.13"
numpy = [
{version = ">=1.19.5, <2.0.0", python = "3.8"}, # for compatibility with scipy
{version = ">=1.22, <2.0.0", python = ">=3.9, <3.12"},
{version = ">=1.26, <2.0.0", python = ">=3.12"} # numpy <1.26 fails to install on Python 3.12
]
pandas = ">=1.5.0, <3.0.0"
scipy = [
{version = "^1.9.1, <1.11", python = "3.8"}, # since 1.11 scipy doesn't support python 3.8
{version = "^1.10.1, <1.13", python = ">=3.9"}, # in 1.13 were introduced significant changes breaking our logic
]
scipy = "^1.10.1, <1.13"
tqdm = "^4.27.0"
implicit = "^0.7.1"
attrs = ">=19.1.0,<24.0.0"
Expand Down
6 changes: 3 additions & 3 deletions rectools/models/dssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def __init__(
self.weight_decay = weight_decay
self.log_to_prog_bar = log_to_prog_bar

def forward( # type: ignore
def forward(
self,
item_features_pos: torch.Tensor,
item_features_neg: torch.Tensor,
Expand All @@ -177,15 +177,15 @@ def configure_optimizers(self) -> torch.optim.Adam:
optimizer = torch.optim.Adam(self.parameters(), lr=self.lr, weight_decay=self.weight_decay)
return optimizer

def training_step(self, batch: tp.Sequence[torch.Tensor], batch_idx: int) -> torch.Tensor: # type: ignore
def training_step(self, batch: tp.Sequence[torch.Tensor], batch_idx: int) -> torch.Tensor:
"""Compute and return the training loss"""
user_features, interactions, pos, neg = batch
anchor, positive, negative = self(pos, neg, user_features, interactions)
loss = F.triplet_margin_loss(anchor, positive, negative, margin=self.triplet_loss_margin)
self.log("loss", loss.item(), prog_bar=self.log_to_prog_bar)
return loss

def validation_step(self, batch: tp.Sequence[torch.Tensor], batch_idx: int) -> torch.Tensor: # type: ignore
def validation_step(self, batch: tp.Sequence[torch.Tensor], batch_idx: int) -> torch.Tensor:
user_features, interactions, pos, neg = batch
anchor, positive, negative = self(pos, neg, user_features, interactions)
val_loss = F.triplet_margin_loss(anchor, positive, negative, margin=self.triplet_loss_margin)
Expand Down
2 changes: 1 addition & 1 deletion rectools/visuals/visual_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def _fill_requests_with_random(
num_selecting = min(len(selecting_from), n_random_requests)
new_ids = np.random.choice(selecting_from, num_selecting, replace=False)
res = selected_requests.copy()
new_requests: tp.Dict[tp.Hashable, ExternalId] = {f"random_{i+1}": new_id for i, new_id in enumerate(new_ids)}
new_requests: tp.Dict[tp.Hashable, ExternalId] = {f"random_{i + 1}": new_id for i, new_id in enumerate(new_ids)}
res.update(new_requests)
return res

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ per-file-ignores =
rectools/models/implicit_als.py: N806

[mypy]
python_version = 3.8
python_version = 3.9
no_incremental = True
ignore_missing_imports = True
disallow_untyped_defs = True
Expand Down
10 changes: 5 additions & 5 deletions tests/dataset/test_torch_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def test_getitem_reconstructs_users(self, dataset: Dataset) -> None:
all_user_features.append(user_features.view(1, -1))
all_interactions.append(interactions.view(1, -1))

all_user_features = torch.cat(all_user_features, 0).numpy()
all_interactions = torch.cat(all_interactions, 0).numpy()
all_user_features = torch.cat(all_user_features, 0).numpy() # type: ignore
all_interactions = torch.cat(all_interactions, 0).numpy() # type: ignore

ui_matrix = dataset.get_user_item_matrix().toarray()
assert np.allclose(all_user_features, dataset.user_features.get_sparse().toarray()) # type: ignore
Expand Down Expand Up @@ -198,8 +198,8 @@ def test_getitem_reconstructs_users(self, dataset: Dataset) -> None:
all_user_features.append(user_features.view(1, -1))
all_interactions.append(interactions.view(1, -1))

all_user_features = torch.cat(all_user_features, 0).numpy()
all_interactions = torch.cat(all_interactions, 0).numpy()
all_user_features = torch.cat(all_user_features, 0).numpy() # type: ignore
all_interactions = torch.cat(all_interactions, 0).numpy() # type: ignore

ui_matrix = dataset.get_user_item_matrix().toarray()
assert np.allclose(all_user_features, dataset.user_features.get_sparse().toarray()) # type: ignore
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_getitem_reconstructs_items(self, dataset: Dataset) -> None:
item_features = items_dataset[idx]
all_item_features.append(item_features.view(1, -1))

all_item_features = torch.cat(all_item_features, 0).numpy()
all_item_features = torch.cat(all_item_features, 0).numpy() # type: ignore
assert np.allclose(all_item_features, dataset.item_features.get_sparse().toarray()) # type: ignore

def test_raises_attribute_error(self, dataset_no_features: Dataset) -> None:
Expand Down