dev container to make standardised asset list to work

This commit is contained in:
Jun-te Kim 2025-09-10 14:36:48 +00:00
parent 78b4aeef63
commit 171c6b7d12
6 changed files with 129 additions and 1 deletions

33
.devcontainer/Dockerfile Normal file
View file

@ -0,0 +1,33 @@
FROM python:3.12-bullseye
ARG USER=vscode
ARG DEBIAN_FRONTEND=noninteractive
# 1) Toolchain + utilities for building libpostal
RUN apt-get update && apt-get install -y --no-install-recommends \
sudo jq vim curl git ca-certificates \
build-essential pkg-config automake autoconf libtool \
&& rm -rf /var/lib/apt/lists/*
# 2) Build and install libpostal from source
RUN git clone --depth 1 https://github.com/openvenues/libpostal /tmp/libpostal \
&& cd /tmp/libpostal \
&& ./bootstrap.sh \
&& ./configure --datadir=/usr/local/share/libpostal \
&& make -j"$(nproc)" \
&& make install \
&& ldconfig \
&& rm -rf /tmp/libpostal
# 3) Create the user and grant sudo privileges
RUN useradd -m -s /usr/bin/bash ${USER} \
&& echo "${USER} ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER}
# 4) Python deps
ENV PIP_NO_CACHE_DIR=1 PIP_DISABLE_PIP_VERSION_CHECK=1
ADD asset_list/requirements.txt requirements.txt
RUN pip install -r requirements.txt
# 5) Workdir
WORKDIR /workspaces/model

View file

@ -0,0 +1,30 @@
{
"name": "Basic Python",
"dockerComposeFile": "docker-compose.yml",
"service": "model",
"remoteUser": "vscode",
"workspaceFolder": "/workspaces/model",
"postStartCommand": "bash .devcontainer/post-install.sh",
"mounts": [
// Optional, just makes getting from Downloads (local env) easier
"source=${localEnv:HOME},target=/workspaces/home,type=bind"
],
"customizations": {
"vscode": {
"settings": {
"files.defaultWorkspace": "/workspaces/model"
},
"extensions": [
"ms-python.python",
"ms-toolsai.jupyter",
"mechatroner.rainbow-csv",
"ms-toolsai.datawrangler",
"lindacong.vscode-book-reader",
"4ops.terraform",
"fabiospampinato.vscode-todo-plus",
"jgclark.vscode-todo-highlight",
"corentinartaud.pdfpreview"
]
}
}
}

View file

@ -0,0 +1,18 @@
version: '3.8'
services:
model:
user: "${UID}:${GID}"
build:
context: ..
dockerfile: .devcontainer/Dockerfile
command: sleep infinity
volumes:
- ..:/workspaces/model
networks:
- model-net
networks:
model-net:
driver: bridge

View file

@ -0,0 +1,27 @@
# #!/bin/bash
# poetry install;
# # Get the Poetry virtual environment path
# VENV_PATH=$(poetry env info --path 2>/dev/null)
# if [ -z "$VENV_PATH" ]; then
# echo "No Poetry environment found. Did you run 'poetry install'?"
# exit 1
# fi
# # Ensure VS Code settings directory exists
# SETTINGS_DIR="/home/vscode/.vscode-server/data/Machine"
# SETTINGS_FILE="$SETTINGS_DIR/settings.json"
# mkdir -p "$SETTINGS_DIR"
# # If settings.json doesn't exist, create a default one
# if [ ! -f "$SETTINGS_FILE" ]; then
# echo "{}" > "$SETTINGS_FILE"
# fi
# # Update VS Code settings to use the Poetry virtual environment
# jq --arg venv "$VENV_PATH/bin/python" '.["python.defaultInterpreterPath"] = $venv' \
# "$SETTINGS_FILE" > "$SETTINGS_FILE.tmp" && mv "$SETTINGS_FILE.tmp" "$SETTINGS_FILE"
# echo "✅ Updated VS Code to use Poetry environment: $VENV_PATH"

19
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,19 @@
{
"jupyter.interactiveWindow.textEditor.executeSelection": true,
"python.REPL.sendToNativeREPL": true,
"notebook.output.scrolling": true,
"terminal.integrated.defaultProfile.linux": "bash",
"editor.rulers": [67],
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
},
// Hot reload setting that needs to be in user settings
// "jupyter.runStartupCommands": [
// "%load_ext autoreload", "%autoreload 2"
// ]
}

View file

@ -12,10 +12,11 @@ from asset_list.utils import get_data
from dotenv import load_dotenv
from backend.SearchEpc import SearchEpc
load_dotenv(dotenv_path="backend/.env")
EPC_AUTH_TOKEN = os.getenv("EPC_AUTH_TOKEN")
print("hello world")
def extract_address1(asset_list, full_address_col, postcode_col, method="first_two_words"):
if method == "first_two_words":