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: 1 addition & 3 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ RUN pip3 install uv
RUN uv pip install -r pyproject.toml
RUN dnf update -y

COPY models/ models/
COPY feature_repo/ feature_repo/
COPY service/ service/
COPY recsysapp/ recsysapp/
# give premisssions
RUN chmod -R 777 . && ls -la

Expand Down
Binary file removed feature_repo/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file removed feature_repo/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file removed feature_repo/__pycache__/entities.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed models/__pycache__/data_util.cpython-311.pyc
Binary file not shown.
Binary file removed models/__pycache__/entity_tower.cpython-311.pyc
Binary file not shown.
Binary file removed models/__pycache__/train_two_tower.cpython-311.pyc
Binary file not shown.
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ dev = [
pythonpath = "."

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.setuptools]
packages = ["models", "service", "generation", "feature_repo"]
[tool.hatch.build.targets.wheel]
packages = ["recsysapp"]
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from feast import FileSource, PushSource
from feast.data_format import ParquetFormat

feast_path = "feature_repo"
data_path = "data"

users_source = FileSource(
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,14 @@ def generate_interactions(
print("\nInteractions sample:")
print(interactions.head())

data_path = pathlib.Path("feature_repo/data")
data_path = pathlib.Path("recsysapp/feature_repo/data")
data_path.mkdir(parents=True, exist_ok=True)

# Save to parquet files
users.to_parquet("feature_repo/data/recommendation_users.parquet", index=False)
items.to_parquet("feature_repo/data/recommendation_items.parquet", index=False)
users.to_parquet(data_path / "recommendation_users.parquet", index=False)
items.to_parquet(data_path / "recommendation_items.parquet", index=False)
interactions.to_parquet(
"feature_repo/data/recommendation_interactions.parquet", index=False
data_path / "recommendation_interactions.parquet", index=False
)

# Create dummy dataframes for push source
Expand Down Expand Up @@ -300,15 +300,15 @@ def generate_interactions(
)

dummy_item_embed_df.to_parquet(
"feature_repo/data/dummy_item_embed.parquet", index=False
data_path / "dummy_item_embed.parquet", index=False
)
dummy_user_embed_df.to_parquet(
"feature_repo/data/dummy_user_embed.parquet", index=False
data_path / "dummy_user_embed.parquet", index=False
)
dummy_user_items_df.to_parquet("feature_repo/data/user_items.parquet", index=False)
dummy_user_items_df.to_parquet(data_path / "user_items.parquet", index=False)
dummy_textual_feature_df.to_parquet(
"feature_repo/data/item_textual_features_embed.parquet", index=False
data_path / "item_textual_features_embed.parquet", index=False
)
dummy_clip_feature_df.to_parquet(
"feature_repo/data/item_clip_features_embed.parquet", index=False
data_path / "item_clip_features_embed.parquet", index=False
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def main():
data_directory = Path(__file__).parent.joinpath("data")
item_df = pd.read_parquet("feature_repo/data/item_df_output.parquet")
item_df = pd.read_parquet("recsysapp/feature_repo/data/item_df_output.parquet")
pprint(item_df)

# Load the Stable Diffusion pipeline (open model)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import torch.nn as nn
from torch.utils.data import DataLoader

from models.data_util import UserItemMagnitudeDataset, preproccess_pipeline
from models.entity_tower import EntityTower
from models.two_tower import TwoTowerModel
from recsysapp.models.data_util import UserItemMagnitudeDataset, preproccess_pipeline
from recsysapp.models.entity_tower import EntityTower
from recsysapp.models.two_tower import TwoTowerModel


def create_and_train_two_tower(
Expand Down
4 changes: 2 additions & 2 deletions models/two_tower.py → recsysapp/models/two_tower.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import torch.nn as nn
from torch import Tensor

from models.item_tower import ItemTower
from models.user_tower import UserTower
from recsysapp.models.item_tower import ItemTower
from recsysapp.models.user_tower import UserTower


class TwoTowerModel(nn.Module):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def __init__(self, data_dir, force_load):
self._loaded = False

if (
self._item_df_path.exists() & self._user_df_path.exists()
& self._interaction_df_path.exists() & force_load is False
self._item_df_path.exists() and self._user_df_path.exists()
and self._interaction_df_path.exists() and (force_load is False)
):
self._item_df = pd.read_parquet(self._item_df_path)
self._user_df = pd.read_parquet(self._user_df_path)
Expand All @@ -52,7 +52,7 @@ def _save_dfs_to_parquet(self):

class LocalDatasetProvider(DatasetProvider):

def __init__(self, store=None, data_dir="./feature_repo/data"):
def __init__(self, store=None, data_dir="./recsysapp/feature_repo/data"):
super().__init__(data_dir, False)
if self._loaded is False:
assert store is not None
Expand Down Expand Up @@ -102,7 +102,7 @@ def _load_from_store(self, store: FeatureStore):

class RemoteDatasetProvider(DatasetProvider):

def __init__(self, url: str, data_dir="./feature_repo/data", force_load=False):
def __init__(self, url: str, data_dir="./recsysapp/feature_repo/data", force_load=False):
super().__init__(data_dir, force_load)
if self._loaded is False:
df = pd.read_csv(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from feast import FeatureStore
from PIL import Image

from service.clip_encoder import ClipEncoder
from recsysapp.service.clip_encoder import ClipEncoder


class SearchByImageService:
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/test_amazon_with_fixed_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pandas as pd
import pytest

from generation.amazon_with_fixed_images import fix_url
from recsysapp.generation.amazon_with_fixed_images import fix_url


@pytest.fixture
Expand All @@ -23,7 +23,7 @@ def test_fix_url(wrong_url, correct_url):

@pytest.fixture()
def base_path():
return Path(__file__).parent.parent.joinpath('feature_repo').joinpath('data')
return Path(__file__).parent.parent.joinpath('recsysapp').joinpath('feature_repo').joinpath('data')


@pytest.fixture
Expand Down
5 changes: 3 additions & 2 deletions tests/test_clip_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import torch
from PIL import Image

from service.clip_encoder import ClipEncoder
from recsysapp.service.clip_encoder import ClipEncoder


@pytest.fixture(scope="session", autouse=True)
Expand Down Expand Up @@ -47,7 +47,8 @@ def simple_images():

generated_image_path = (
Path(__file__)
.parent.parent.joinpath("generation")
.parent.parent.joinpath("recsysapp")
.joinpath("generation")
.joinpath("data")
.joinpath("generated_images")
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_create_and_train_two_tower.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pandas as pd
import pytest

from models.entity_tower import EntityTower
from models.train_two_tower import create_and_train_two_tower
from recsysapp.models.entity_tower import EntityTower
from recsysapp.models.train_two_tower import create_and_train_two_tower


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
import torch

from models.data_util import data_preproccess
from recsysapp.models.data_util import data_preproccess


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/test_entity_tower.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import torch

from models.entity_tower import EntityTower
from recsysapp.models.entity_tower import EntityTower

D_MODEL = 64
DIM_RATIO = {"numeric": 1, "categorical": 2, "text": 7, "image": 0}
Expand Down
6 changes: 3 additions & 3 deletions tests/test_search_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
import torch

from service.search_by_text import SearchService
from recsysapp.service.search_by_text import SearchService


@pytest.fixture
Expand Down Expand Up @@ -33,8 +33,8 @@ def mock_feature_store():
@pytest.fixture
def search_service(mock_feature_store):
with (
patch("service.search_by_text.AutoTokenizer") as mock_tokenizer,
patch("service.search_by_text.AutoModel") as mock_model,
patch("recsysapp.service.search_by_text.AutoTokenizer") as mock_tokenizer,
patch("recsysapp.service.search_by_text.AutoModel") as mock_model,
):
# Mock the tokenizer
mock_tokenizer.from_pretrained.return_value = Mock()
Expand Down
Loading