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

Migrate to Python 3.12 and uv package management #40

Merged
merged 1 commit into from
Feb 19, 2025
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
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
# Allow manual trigger
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build-and-deploy:
runs-on: ubuntu-latest
Expand Down
39 changes: 27 additions & 12 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,36 @@ on:
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
# Run pylint to check for code quality
pylint:
# Run ruff to check for code quality
ruff:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: 3.11
python-version: "3.12"

- name: Install dependencies
- name: Install uv
run: |
pip3 install pylint
pip3 install -r requirements.txt
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Run pylint
- name: Install dependencies
run: |
pylint .
uv pip sync --system pyproject.toml
uv pip install --system ruff

- name: Run ruff
run: ruff check .

# Run Bandit to check for common security vulnerabilities
bandit:
Expand All @@ -34,13 +42,20 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: 3.11
python-version: "3.12"

- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install dependencies
run: pip3 install bandit
run: |
uv pip sync --system pyproject.toml
uv pip install --system bandit

- name: Run Bandit
run: bandit -r .
9 changes: 0 additions & 9 deletions .pylintrc

This file was deleted.

1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-slim-bookworm
FROM python:3.12-slim-bookworm

# Set the working directory
RUN mkdir -p /usr/src/app
Expand All @@ -21,10 +21,13 @@ RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /us
apt-get update && \
ACCEPT_EULA=Y apt-get install -y msodbcsql17

# Upgrade pip and install Python dependencies
RUN pip3 install --upgrade pip
COPY requirements.txt /usr/src/app/
RUN pip3 install -r requirements.txt
# Install uv and use it to install dependencies
RUN curl -LsSf https://astral.sh/uv/install.sh | sh

# Add uv to PATH and install dependencies
ENV PATH="/root/.local/bin:$PATH"
COPY pyproject.toml /usr/src/app/
RUN uv pip sync --system pyproject.toml

# Copy the source code
COPY . /usr/src/app
Expand Down
8 changes: 4 additions & 4 deletions chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def __init__(self):
self.system_prompt = {
"role": "system",
"content": (
"You are an AI assistant designed to help students from the University of Amsterdam. " # pylint: disable=C0321
"Provide clear and concise answers based solely on the information provided in the conversation " # pylint: disable=C0321
"and documents. Do not provide false information or content not mentioned in the documents. " # pylint: disable=C0321
"Use relevant knowledge when needed. Avoid mentioning that your information comes from the documents." # pylint: disable=C0321
"You are an AI assistant designed to help students from the University of Amsterdam. "
"Provide clear and concise answers based solely on the information provided in the conversation "
"and documents. Do not provide false information or content not mentioned in the documents. "
"Use relevant knowledge when needed. Avoid mentioning that your information comes from the documents."
),
}

Expand Down
102 changes: 102 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[project]
name = "studentwhisperer"
version = "0.1.0"
description = "Student Whisperer is an AI-powered chatbot designed to help students from the University of Amsterdam with their questions and concerns."
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"aiohappyeyeballs==2.4.6",
"aiohttp==3.11.12",
"aiosignal==1.3.2",
"altair==5.5.0",
"annotated-types==0.7.0",
"anthropic==0.45.2",
"anyio==4.8.0",
"attrs==25.1.0",
"azure-common==1.1.28",
"azure-core==1.32.0",
"azure-search-documents==11.5.2",
"blinker==1.9.0",
"cachetools==5.5.1",
"certifi==2025.1.31",
"charset-normalizer==3.4.1",
"click==8.1.8",
"colorama==0.4.6",
"dataclasses-json==0.6.7",
"distro==1.9.0",
"duckduckgo-search==7.3.2",
"frozenlist==1.5.0",
"gitdb==4.0.12",
"gitpython==3.1.44",
"greenlet==3.1.1",
"h11==0.14.0",
"httpcore==1.0.7",
"httpx==0.28.1",
"httpx-sse==0.4.0",
"idna==3.10",
"isodate==0.7.2",
"jinja2==3.1.5",
"jiter==0.8.2",
"jsonpatch==1.33",
"jsonpointer==3.0.0",
"jsonschema==4.23.0",
"jsonschema-specifications==2024.10.1",
"langchain==0.3.18",
"langchain-community==0.3.17",
"langchain-core==0.3.35",
"langchain-text-splitters==0.3.6",
"langsmith==0.3.8",
"lxml==5.3.1",
"markdown-it-py==3.0.0",
"markupsafe==3.0.2",
"marshmallow==3.26.1",
"mdurl==0.1.2",
"multidict==6.1.0",
"mypy-extensions==1.0.0",
"narwhals==1.26.0",
"numpy==1.26.4",
"openai==1.62.0",
"orjson==3.10.15",
"packaging==24.2",
"pandas==2.2.3",
"pillow==11.1.0",
"primp==0.12.1",
"propcache==0.2.1",
"protobuf==5.29.3",
"pyarrow==19.0.0",
"pydantic==2.10.6",
"pydantic-core==2.27.2",
"pydantic-settings==2.7.1",
"pydeck==0.9.1",
"pygments==2.19.1",
"pyodbc>=4.0.30",
"python-dateutil==2.9.0.post0",
"python-dotenv==1.0.1",
"pytz==2025.1",
"pyyaml==6.0.2",
"referencing==0.36.2",
"requests==2.32.3",
"requests-toolbelt==1.0.0",
"rich==13.9.4",
"rpds-py==0.22.3",
"six==1.17.0",
"smmap==5.0.2",
"sniffio==1.3.1",
"sqlalchemy==2.0.38",
"streamlit==1.42.0",
"tenacity==9.0.0",
"toml==0.10.2",
"tornado==6.4.2",
"tqdm==4.67.1",
"trubrics==1.8.2",
"typing-extensions==4.12.2",
"typing-inspect==0.9.0",
"tzdata==2025.1",
"urllib3==2.3.0",
"watchdog==6.0.0",
"yarl==1.18.3",
"zstandard==0.23.0",
]

[dependency-groups]
dev = ["ruff>=0.9.6"]
92 changes: 0 additions & 92 deletions requirements.txt

This file was deleted.

Loading