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

Develop #37

Merged
merged 24 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cce5e64
🌈 style: Refactor paper parsing methods
AndPuQing Feb 23, 2024
f03145c
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] Feb 23, 2024
5f96ace
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] Feb 23, 2024
28f0e6a
✨ feat(celery): Add celerybeat image and configuration
AndPuQing Feb 24, 2024
ffa6e82
🦄 refactor(Task): Add rate limit to PaperRequestsTask and RSSTask
AndPuQing Feb 24, 2024
195aa71
🦄 refactor(PaperTask): Refactor periodic task setup and paper crawler…
AndPuQing Feb 24, 2024
a9984a5
🦄 refactor: Refactor parse_urls method in AAAI and NIPS classes
AndPuQing Feb 24, 2024
157686e
✨ feat: Add gensim library and update Python version in Dockerfiles
AndPuQing Feb 24, 2024
5a7b217
✨ feat: Add doc2vec functionality and test endpoint
AndPuQing Feb 24, 2024
682e062
🦄 refactor: Update Python version and add rectools dependency
AndPuQing Feb 25, 2024
9d5b99c
✨ feat(endpoints): Add DATA_SIZE configuration and test recommender e…
AndPuQing Feb 25, 2024
4d631bf
✨ feat(worker): Add LightFM and ImplicitALSWrapperModel for recommend…
AndPuQing Feb 25, 2024
a79d399
🦄 refactor(just): Remove dev-logs command from justfile
AndPuQing Feb 25, 2024
ff424ac
🦄 refactor(infer): Refactor worker imports and add new feedback type
AndPuQing Feb 25, 2024
0e229b5
🦄 refactor(init): Add cold start for recommender and item feedback
AndPuQing Feb 25, 2024
1075b57
✨ feat(email): Add new email templates and dependencies
AndPuQing Feb 25, 2024
f2f9dc1
🦄 refactor: Update email templates directory path
AndPuQing Feb 25, 2024
24fd946
🦄 refactor: Refactor email recommendation template and fix variable n…
AndPuQing Feb 25, 2024
4e2969d
🦄 refactor(docker): Refactor Dockerfile to simplify installation of d…
AndPuQing Feb 25, 2024
93387b9
🦄 refactor: Refactor code and add train_test_split function
AndPuQing Feb 25, 2024
0ca300b
🔧 build: Update database configuration for testing
AndPuQing Feb 25, 2024
3dbdc49
Merge branch 'main' into develop
AndPuQing Feb 25, 2024
a1ed5e0
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] Feb 25, 2024
9927c75
Update fastapi version to 0.109.2
AndPuQing Feb 25, 2024
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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ DOMAIN=localhost
# Configure these with your own Docker registry images
DOCKER_IMAGE_BACKEND=backend
DOCKER_IMAGE_CELERYWORKER=celerywork
DOCKER_IMAGE_CELERYBEAT=celerybeat

# Backend
BACKEND_CORS_ORIGINS="[\"http://localhost\", \"http://localhost:4200\", \"http://localhost:3000\", \"http://localhost:8080\", \"https://localhost\", \"https://localhost:4200\", \"https://localhost:3000\", \"https://localhost:8080\", \"http://local.dockertoolbox.tiangolo.com\", \"http://localhost.tiangolo.com\"]"
PROJECT_NAME="BeMore"
SECRET_KEY=changethis
SMTP_TLS=True
Expand Down
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ __pycache__
app.egg-info
*.pyc
coverage.xml
*.pkl
1 change: 1 addition & 0 deletions backend/app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.coverage
htmlcov
celerybeat-schedule
13 changes: 9 additions & 4 deletions backend/app/app/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@
from app.web.application import get_app


@pytest.fixture(name="session")
def session_fixture():
@pytest.fixture(scope="session")
def engine_fixture():
engine = create_engine(
f"postgresql+psycopg://{settings.POSTGRES_USER}:{settings.POSTGRES_PASSWORD}@bemore-db/{settings.POSTGRES_DB}",
f"postgresql+psycopg://{settings.POSTGRES_USER}:{settings.POSTGRES_PASSWORD}@bemore-db/test",
)
SQLModel.metadata.create_all(engine)

with Session(engine) as session:
init_db(session)
yield engine


@pytest.fixture(name="session")
def session_fixture(engine_fixture):
with Session(engine_fixture) as session:
yield session


Expand Down
4 changes: 3 additions & 1 deletion backend/app/app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ class Settings(BaseSettings):
SMTP_USER: str = ""
SMTP_PASSWORD: str = ""

EMAIL_TEMPLATES_DIR: str = "bemore/email-templates/build"
EMAIL_TEMPLATES_DIR: str = "/app/app/email-templates/"

# requests settings
REQUESTS_BATCH_SIZE: int = 2
CRAWL_INTERVAL: int = 60 * 60 * 24 * 7 # 1 week
DATA_SIZE: int = 100

model_config = SettingsConfigDict(
env_file=".env",
Expand Down
42 changes: 41 additions & 1 deletion backend/app/app/db/init_db.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import csv
import logging
import random

from sqlmodel import Session, SQLModel, select

from app.core.config import settings
from app.db.engine import engine
from app.models import User, UserCreate # noqa: F401
from app.models import (
FeedBack,
Item,
User,
UserCreate,
)


def init_db(session: Session) -> None:
Expand All @@ -20,6 +27,39 @@ def init_db(session: Session) -> None:
user = User.create(session, user_in)
logging.debug(f"Superuser {settings.FIRST_SUPERUSER} created")

# cold start for the recommender
users = [f"{i}@bemore.com" for i in range(1, 11)]
for email in users:
user_in = UserCreate(
email=email,
password="123456",
is_active=False,
)
user = User.create(session, user_in)

with open("/app/app/db/item.csv", "r") as file:
reader = csv.reader(file)
for i, row in enumerate(reader):
if i == 0:
continue
item_in = Item(
title=row[0],
abstract=row[1],
url=row[4],
from_source=row[5],
)
item = Item.create(session, item_in)

for user_id in range(1, 11):
for i in range(1, 20):
feedback = FeedBack(
user_id=user_id,
item_id=random.randint(1, 100),
feedback_type=1.0,
)
session.add(feedback)
session.commit()


async def init():
with Session(engine) as session:
Expand Down
184 changes: 184 additions & 0 deletions backend/app/app/db/item.csv

Large diffs are not rendered by default.

Loading