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

chore: switch to uv #2224

Merged
merged 2 commits into from
Nov 25, 2024
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
12 changes: 6 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"image": "mcr.microsoft.com/devcontainers/python:3.12",
"features": {
"ghcr.io/devcontainers-contrib/features/pdm:2": {},
"ghcr.io/itsmechlark/features/1password:1": {},
"ghcr.io/trunk-io/devcontainer-feature/trunk:1": {}
},
"postCreateCommand": "bash .devcontainer/scripts/postCreate.sh",
"postStartCommand": "bash .devcontainer/scripts/postStart.sh",
"containerEnv": {
"PYTHONDONTWRITEBYTECODE": "1",
"USE_GKE_GCLOUD_AUTH_PLUGIN": "True",
"GOOGLE_APPLICATION_CREDENTIALS": "/etc/secret-volume/gcloud_service_account_json",
"DBT_PROFILES_DIR": "/workspaces/teamster/.dbt",
"DAGSTER_HOME": "/workspaces/teamster/.dagster/home",
"TRUNK_TELEMETRY": "off"
"DBT_PROFILES_DIR": "/workspaces/teamster/.dbt",
"PYTHONDONTWRITEBYTECODE": "1",
"TRUNK_TELEMETRY": "off",
"UV_ENV_FILE": "env/.env",
"UV_LINK_MODE": "copy",
"UV_RESOLUTION": "highest"
},
"customizations": {
"vscode": {
Expand Down
35 changes: 18 additions & 17 deletions .devcontainer/scripts/postCreate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ git config pull.rebase false # merge
# update/install apt packages
sudo apt-get -y --no-install-recommends update &&
sudo apt-get -y --no-install-recommends upgrade &&
sudo apt-get -y --no-install-recommends install \
bash-completion &&
sudo apt-get -y --no-install-recommends install bash-completion &&
sudo rm -rf /var/lib/apt/lists/*

# create env folder
mkdir -p ./env
mkdir -p /home/vscode/.dbt
sudo mkdir -p /etc/secret-volume

# inject 1Password secrets into .env
Expand Down Expand Up @@ -53,25 +51,28 @@ op inject -f --in-file=.devcontainer/tpl/dbt_cloud.yml.tpl \
--out-file=env/dbt_cloud.yml &&
sudo mv -f env/dbt_cloud.yml /home/vscode/.dbt/dbt_cloud.yml

# install pdm dependencies
pdm install --frozen-lockfile
# install uv
curl -LsSf https://astral.sh/uv/install.sh | sh || true

# install dependencies
uv sync --frozen

# prepare dbt projects
pdm run dagster-dbt project prepare-and-package \
uv run dagster-dbt project prepare-and-package \
--file src/teamster/code_locations/kippcamden/__init__.py
pdm run dagster-dbt project prepare-and-package \
uv run dagster-dbt project prepare-and-package \
--file src/teamster/code_locations/kippmiami/__init__.py
pdm run dagster-dbt project prepare-and-package \
uv run dagster-dbt project prepare-and-package \
--file src/teamster/code_locations/kippnewark/__init__.py
pdm run dagster-dbt project prepare-and-package \
uv run dagster-dbt project prepare-and-package \
--file src/teamster/code_locations/kipptaf/__init__.py

# install dbt deps for packages
pdm run dbt deanslist deps
pdm run dbt edplan deps
pdm run dbt iready deps
pdm run dbt overgrad deps
pdm run dbt pearson deps
pdm run dbt powerschool deps
pdm run dbt renlearn deps
pdm run dbt titan deps
uv run dbt deps --project-dir=src/dbt/deanslist
uv run dbt deps --project-dir=src/dbt/edplan
uv run dbt deps --project-dir=src/dbt/iready
uv run dbt deps --project-dir=src/dbt/overgrad
uv run dbt deps --project-dir=src/dbt/pearson
uv run dbt deps --project-dir=src/dbt/powerschool
uv run dbt deps --project-dir=src/dbt/renlearn
uv run dbt deps --project-dir=src/dbt/titan
7 changes: 2 additions & 5 deletions .devcontainer/scripts/postStart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
# inject 1Password secrets into .env
op inject -f --in-file=.devcontainer/tpl/.env.tpl --out-file=env/.env

# update pip
sudo python -m pip install --no-cache-dir --upgrade pip

# update pdm
sudo /usr/local/py-utils/bin/pdm self update
# update uv
uv self update

# update trunk
trunk upgrade -y --no-progress
7 changes: 2 additions & 5 deletions .github/workflows/uv-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@ jobs:
- name: Install Python 3.12
run: uv python install 3.12

- name: Setup uv venv
run: uv venv

- name: Install requirements.txt
run: uv pip install -r requirements.txt --override overrides.txt --no-cache-dir
- name: Install dependencies
run: uv sync --frozen --no-dev --no-install-project --no-editable
20 changes: 0 additions & 20 deletions .pdm/scripts/clean.sh

This file was deleted.

17 changes: 0 additions & 17 deletions .pdm/scripts/dbt.sh

This file was deleted.

40 changes: 17 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,32 @@ FROM python:"${PYTHON_VERSION}"-slim

ARG CODE_LOCATION

# set shell to bash
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# set container envs
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PATH=/app/.venv/bin:"${PATH}"
ENV UV_LINK_MODE=copy

# set workdir
WORKDIR /app

# install uv & create venv
RUN --mount=type=cache,target=/root/.cache/pip \
pip install "uv==0.5.0" --no-cache-dir \
&& uv venv

# install dependencies
COPY pyproject.toml requirements.txt overrides.txt ./
RUN --mount=type=cache,target=/root/.cache/pip \
uv pip install \
-r requirements.txt \
--override overrides.txt \
--no-cache-dir

# install python project
COPY src/teamster/ ./src/teamster/
RUN uv pip install \
-e . \
--override overrides.txt \
--no-cache-dir
# Install dependencies
RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv \
--mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-dev --no-install-project --compile-bytecode --no-editable

# Copy the project into the image
COPY . /app

# Sync the project
RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv \
--mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
uv sync --frozen --no-dev --no-editable

# install dbt project
COPY src/dbt/ ./src/dbt/
RUN dagster-dbt project prepare-and-package \
--file src/teamster/code_locations/"${CODE_LOCATION}"/__init__.py
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![kippcamden](https://github.com/TEAMSchools/teamster/actions/workflows/deploy-prod-kippcamden.yaml/badge.svg)](https://github.com/TEAMSchools/teamster/actions/workflows/deploy-prod-kippcamden.yaml)
[![kippmiami](https://github.com/TEAMSchools/teamster/actions/workflows/deploy-prod-kippmiami.yaml/badge.svg)](https://github.com/TEAMSchools/teamster/actions/workflows/deploy-prod-kippmiami.yaml)

[![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm.fming.dev)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
[![Trunk](https://img.shields.io/badge/trunk-checked-brightgreen?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHN0cm9rZT0iI0ZGRiIgc3Ryb2tlLXdpZHRoPSIxMSIgdmlld0JveD0iMCAwIDEwMSAxMDEiPjxwYXRoIGQ9Ik01MC41IDk1LjVhNDUgNDUgMCAxIDAtNDUtNDVtNDUtMzBhMzAgMzAgMCAwIDAtMzAgMzBtNDUgMGExNSAxNSAwIDAgMC0zMCAwIi8+PC9zdmc+)](https://trunk.io)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
Expand Down
Empty file removed overrides.txt
Empty file.
Loading
Loading