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
5 changes: 3 additions & 2 deletions .github/workflows/alembic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ jobs:
POSTGRES_HOST_AUTH_METHOD: trust

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 1

- name: Wait for PostgreSQL to be ready
run: |
Expand All @@ -32,7 +34,6 @@ jobs:

- name: Install dependencies
run: |
# for python3.11 (dear internet gods: we'll update to 3.13 or something in a year, i promise)
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.13 python3.13-venv
python3.13 -m pip install --upgrade pip
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pytest_unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jobs:
timeout-minutes: 5

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

- uses: actions/setup-python@v4
- uses: actions/setup-python@v6
with:
python-version: '3.13'

- uses: actions/cache@v4
- uses: actions/cache@v5
id: cache
with:
path: ~/.cache/pip
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
with:
version: 0.15.12
- uses: actions/checkout@v6
- uses: astral-sh/ruff-action@v3
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ If you're planning to read through the source code, please check out this projec

### Quickstart

1. Install [Python 3.11](https://www.python.org/downloads/), [git](https://git-scm.com/install/), and (optionally) [Docker](https://www.docker.com/get-started/)
Note: This may fail if you're using Python 3.12+
1. Install [Python 3.13](https://www.python.org/downloads/), [git](https://git-scm.com/install/), and (optionally) [Docker](https://www.docker.com/get-started/)
2. Clone this repository
3. Create and activate a virtual environment for this project. This has been tested with `pip` and `uv`
4. Install developer dependencies
Expand Down Expand Up @@ -57,5 +56,5 @@ export LOCAL=true # Should be true if you're running this locally

## Developer Tools

We use `ruff 0.6.9` as our linter, which you can run with `ruff check --fix`. If you use a different version, it may be inconsistent with our CI checks.
We use `ruff` as our linter, which you can run with `ruff check --fix`. If you use a different version, it may be inconsistent with our CI checks.
We use `pyright/basedpyright` for typechecking. Language services have been left enabled and will be changed if it becomes an issue.
6 changes: 4 additions & 2 deletions src/auth/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import urllib.parse

import requests # TODO: make this async
import httpx
import xmltodict
from fastapi import APIRouter, BackgroundTasks, HTTPException, Request, Response
from fastapi.responses import JSONResponse, RedirectResponse
Expand Down Expand Up @@ -54,7 +54,9 @@ async def login_user(
service_url = body.service
service = urllib.parse.quote(service_url)
service_validate_url = f"https://cas.sfu.ca/cas/serviceValidate?service={service}&ticket={body.ticket}"
cas_response = xmltodict.parse(requests.get(service_validate_url).text)
async with httpx.AsyncClient() as client:
response = await client.get(service_validate_url)
cas_response = xmltodict.parse(response.text)

if "cas:authenticationFailure" in cas_response["cas:serviceResponse"]:
_logger.info(f"User failed to login, with response {cas_response}")
Expand Down
3 changes: 3 additions & 0 deletions src/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Annotated, Any

import asyncpg
import httpx
import sqlalchemy
from fastapi import Depends, FastAPI
from sqlalchemy import MetaData
Expand Down Expand Up @@ -115,7 +116,9 @@ async def lifespan(app: FastAPI):
"""
Handles startup and shutdown events, see https://fastapi.tiangolo.com/advanced/events/
"""
app.state.http_client = httpx.AsyncClient()
yield
await app.state.http_client.aclose()
if sessionmanager._engine is not None:
# Close the DB connection
await sessionmanager.close()
Expand Down
Loading