Skip to content
Closed
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: 2 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ isort = "^5.12.0"
pyright = "^1.1.324"
numpy = "1.26.4"
google-cloud-storage = "^3.1.0"
duckdb = "^1.5.4"
pyarrow = "^20.0.0"

[tool.poetry.group.dev.dependencies]
pyinstrument = "^4.6.1"
Expand Down
2 changes: 2 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ certifi==2025.1.31
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
duckdb==1.5.4
exceptiongroup==1.2.2
fastapi==0.101.1
flake8==6.1.0
Expand Down Expand Up @@ -36,6 +37,7 @@ platformdirs==4.3.7
proto-plus==1.26.1
protobuf==6.30.2
psycopg2==2.9.10
pyarrow==20.0.0
pyasn1-modules==0.4.2
pyasn1==0.6.1
pycodestyle==2.11.1
Expand Down
47 changes: 47 additions & 0 deletions backend/src/api/backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import os

if os.environ.get("API_BACKEND", "").lower() == "duckdb":
from src.db_duckdb import (
get_event,
get_events,
get_match,
get_matches,
get_team,
get_team_event,
get_team_events,
get_team_year,
get_team_years,
get_teams,
get_year,
get_years,
)
else:
from src.db.read import (
get_event,
get_events,
get_match,
get_matches,
get_team,
get_team_event,
get_team_events,
get_team_year,
get_team_years,
get_teams,
get_year,
get_years,
)

__all__ = [
"get_event",
"get_events",
"get_match",
"get_matches",
"get_team_event",
"get_team_events",
"get_team_year",
"get_team_years",
"get_team",
"get_teams",
"get_year",
"get_years",
]
2 changes: 1 addition & 1 deletion backend/src/api/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
year_query,
)
from src.db.models import Event
from src.db.read import get_event, get_events
from src.api.backend import get_event, get_events
from src.utils.alru_cache import alru_cache
from src.utils.decorators import (
async_fail_gracefully_plural,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
year_query,
)
from src.db.models import Match
from src.db.read import get_match, get_matches
from src.api.backend import get_match, get_matches
from src.utils.alru_cache import alru_cache
from src.utils.decorators import (
async_fail_gracefully_plural,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
state_query,
)
from src.db.models import Team
from src.db.read import get_team, get_teams
from src.api.backend import get_team, get_teams
from src.utils.alru_cache import alru_cache
from src.utils.decorators import (
async_fail_gracefully_plural,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/team_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
year_query,
)
from src.db.models import TeamEvent
from src.db.read import get_team_event, get_team_events
from src.api.backend import get_team_event, get_team_events
from src.utils.alru_cache import alru_cache
from src.utils.decorators import (
async_fail_gracefully_plural,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/team_year.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
year_query,
)
from src.db.models import TeamYear
from src.db.read import get_team_year, get_team_years
from src.api.backend import get_team_year, get_team_years
from src.utils.alru_cache import alru_cache
from src.utils.decorators import (
async_fail_gracefully_plural,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/year.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from src.api.query import ascending_query, limit_query, metric_query, offset_query
from src.db.models import Year
from src.db.read import get_year, get_years
from src.api.backend import get_year, get_years
from src.utils.alru_cache import alru_cache
from src.utils.decorators import (
async_fail_gracefully_plural,
Expand Down
8 changes: 7 additions & 1 deletion backend/src/data/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
update_team_years as update_team_years_db,
update_teams as update_teams_db,
)
from src.google.parquet import build_parquet_uploads, write_parquet
from src.google.snapshot import read_snapshot, write_snapshot
from src.google.storage import write_objs as write_objs_storage

Expand Down Expand Up @@ -83,7 +84,8 @@ def process_year(
write_snapshot(year_num, objs, teams)
timer.print(str(year_num) + " Write Snapshot")

write_objs_storage(objs, orig_objs if partial else None, teams)
parquet_uploads = build_parquet_uploads(year_num, objs, teams)
write_objs_storage(objs, orig_objs if partial else None, teams, parquet_uploads)
timer.print(str(year_num) + " Write Storage")

try:
Expand All @@ -96,6 +98,10 @@ def process_year(
write_objs_db(year_num, objs, orig_objs if partial else None, not partial)
timer.print(str(year_num) + " Write DB")

if not DISABLE_GCS:
write_parquet(year_num, objs, teams)
timer.print(str(year_num) + " Write Parquet")

return teams


Expand Down
29 changes: 29 additions & 0 deletions backend/src/db_duckdb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from src.db_duckdb.main import (
get_event,
get_events,
get_match,
get_matches,
get_team,
get_team_event,
get_team_events,
get_team_year,
get_team_years,
get_teams,
get_year,
get_years,
)

__all__ = [
"get_event",
"get_events",
"get_match",
"get_matches",
"get_team_event",
"get_team_events",
"get_team_year",
"get_team_years",
"get_team",
"get_teams",
"get_year",
"get_years",
]
Loading