Skip to content

Commit b82c8a4

Browse files
Merge pull request #21 from switchbox-data/20-mini-analysis-with-visualizations
This big merge allows the reset to the workflow that this project underwent starting 12/5. Details to be found on the #il_smart_meter_project thread on Slack.
2 parents 7351d2f + d6424da commit b82c8a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+13437
-824
lines changed

.devcontainer/devcontainer.json

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,61 @@
1-
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2-
// README at: https://github.com/devcontainers/templates/tree/main/src/python
1+
// .devcontainer/devcontainer.json
2+
33
{
4-
"name": "smart-meter-analysis",
5-
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "mcr.microsoft.com/devcontainers/python:1-3.13",
7-
8-
// Use 'postCreateCommand' to run commands after the container is created.
9-
"postCreateCommand": "./.devcontainer/postCreateCommand.sh",
10-
11-
// Configure tool-specific properties.
12-
"customizations": {
13-
"vscode": {
14-
"extensions": ["ms-python.python", "editorconfig.editorconfig"],
15-
"settings": {
16-
"python.testing.pytestArgs": ["tests"],
17-
"python.testing.unittestEnabled": false,
18-
"python.testing.pytestEnabled": true,
19-
"python.defaultInterpreterPath": "/workspaces/smart-meter-analysis/.venv/bin/python",
20-
"python.testing.pytestPath": "/workspaces/smart-meter-analysis/.venv/bin/pytest"
21-
}
22-
}
4+
"name": "smart_meter_analysis",
5+
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
6+
7+
// Install Quarto CLI and Chromium
8+
"features": {
9+
"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {
10+
"installChromium": true
11+
},
12+
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
13+
"packages": "chromium"
14+
},
15+
"ghcr.io/guiyomh/features/just:0.1.0": {
16+
"version": "1.40.0"
17+
},
18+
"ghcr.io/devcontainers/features/aws-cli:1": {
19+
"version": "2.27.4"
20+
}
21+
},
22+
23+
"initializeCommand": "mkdir -p ${localEnv:HOME}/.aws",
24+
"mounts": [
25+
"source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached"
26+
],
27+
"remoteEnv": {
28+
"AWS_REGION": "us-west-2"
29+
},
30+
31+
// Run after the container is created to install uv, create .venv, and install deps
32+
"postCreateCommand": "./.devcontainer/postCreateCommand.sh",
33+
34+
// Tell Quarto to use the Python interpreter in the uv-managed virtual environment.
35+
"containerEnv": {
36+
"QUARTO_PYTHON": "/workspaces/smart-meter-analysis/.venv/bin/python"
37+
},
38+
39+
"customizations": {
40+
"vscode": {
41+
"extensions": [
42+
"ms-python.python",
43+
"editorconfig.editorconfig",
44+
"quarto.quarto",
45+
"nefrob.vscode-just-syntax"
46+
],
47+
"settings": {
48+
"python.testing.pytestArgs": ["tests"],
49+
"python.testing.unittestEnabled": false,
50+
"python.testing.pytestEnabled": true,
51+
52+
// Use the uv-created virtual environment
53+
"python.defaultInterpreterPath": "/workspaces/smart-meter-analysis/.venv/bin/python",
54+
"python.testing.pytestPath": "/workspaces/smart-meter-analysis/.venv/bin/pytest",
55+
56+
// Let the Python extension auto-activate the environment in its own terminals
57+
"python.terminal.activateEnvironment": true
58+
}
2359
}
60+
}
2461
}

.devcontainer/postCreateCommand.sh

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,59 @@
11
#!/usr/bin/env bash
2-
set -e
2+
set -euo pipefail
33

44
echo "Starting post-create setup..."
55

6-
# Install uv
7-
echo "Installing uv..."
8-
curl -LsSf https://astral.sh/uv/install.sh | sh
6+
# Always work from the workspace root inside the container
7+
cd /workspaces/smart-meter-analysis
98

10-
# Source the shell to get uv in PATH
11-
# export PATH="$HOME/.cargo/bin:$PATH"
9+
# Install uv only if it's not already available
10+
if ! command -v uv >/dev/null 2>&1; then
11+
echo "Installing uv..."
12+
curl -LsSf https://astral.sh/uv/install.sh | sh
13+
else
14+
echo "uv already installed, skipping install."
15+
fi
16+
17+
# Ensure uv is on PATH for this script run (covers common install locations)
18+
export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
1219

1320
# Clean any corrupted venv from previous runs
1421
echo "Cleaning any existing venv..."
1522
rm -rf .venv
1623

17-
# Install Dependencies
24+
# Install dependencies (creates & manages .venv)
1825
echo "Installing dependencies with uv sync..."
1926
uv sync
2027

2128
# Install pre-commit hooks
2229
echo "Installing pre-commit hooks..."
2330
uv run pre-commit install --install-hooks
2431

32+
# -------------------------------------------------------------------
33+
# Auto-activate .venv for ALL future interactive bash sessions
34+
# -------------------------------------------------------------------
35+
BASHRC="/home/vscode/.bashrc"
36+
SNIPPET_START="# >>> smart-meter-analysis venv auto-activate >>>"
37+
SNIPPET_END="# <<< smart-meter-analysis venv auto-activate <<<"
38+
39+
# Remove old snippet if it exists (idempotent)
40+
if grep -q "$SNIPPET_START" "$BASHRC" 2>/dev/null; then
41+
echo "Removing existing venv auto-activate snippet from .bashrc..."
42+
# delete lines between markers
43+
sed -i "/$SNIPPET_START/,/$SNIPPET_END/d" "$BASHRC"
44+
fi
45+
46+
echo "Adding venv auto-activate snippet to .bashrc..."
47+
cat << 'EOF' >> "$BASHRC"
48+
# >>> smart-meter-analysis venv auto-activate >>>
49+
if [ -d "/workspaces/smart-meter-analysis/.venv" ]; then
50+
cd /workspaces/smart-meter-analysis
51+
# only activate if not already in this venv
52+
if [ -z "$VIRTUAL_ENV" ] || [ "$VIRTUAL_ENV" != "/workspaces/smart-meter-analysis/.venv" ]; then
53+
. /workspaces/smart-meter-analysis/.venv/bin/activate
54+
fi
55+
fi
56+
# <<< smart-meter-analysis venv auto-activate <<<
57+
EOF
58+
2559
echo "Post-create setup completed successfully!"

.github/workflows/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ jobs:
2323
uses: ./.github/actions/setup-python-env
2424

2525
- name: Run checks
26-
run: make check
26+
run: |
27+
uv lock --locked
28+
uv run pre-commit run -a
29+
uv run mypy
30+
uv run deptry .
2731
2832
tests-and-type-check:
2933
runs-on: ubuntu-latest

.gitignore

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,26 @@ cython_debug/
147147
*.kml
148148
*.zip
149149

150-
# Ameren scraper files
151-
scripts/.secrets/
152-
data/raw/
150+
# Passwords etc...
151+
.secrets/
152+
153+
# Data files
154+
data/
155+
156+
# Temporary files
157+
scratch/
158+
*_sample_*.csv
159+
test_*.py
160+
debug_*.py
161+
162+
# Debug files
163+
*_sample_*.csv
164+
validate_*.py.bak
165+
archive/
166+
167+
# generated artifacts
168+
out/
169+
results/
170+
171+
# benchmark artificats
172+
profiles/

.ruffignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
archive/
2+
archive/

0 commit comments

Comments
 (0)