Skip to content

Commit a930ac0

Browse files
authored
feat(devcontainer): enhance development environment setup (#28)
1 parent 3fcc6b6 commit a930ac0

File tree

2 files changed

+114
-45
lines changed

2 files changed

+114
-45
lines changed

.devcontainer/devcontainer.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
1111
"ghcr.io/devcontainers/features/git:1": {},
1212
"ghcr.io/devcontainers/features/azure-cli:1": {
13-
"extensions": "connectedk8s,k8s-extension,azure-iot-ops,amg,eventgrid"
13+
"extensions": "connectedk8s,k8s-extension,azure-iot-ops,amg,eventgrid,ml"
1414
},
1515
"ghcr.io/devcontainers/features/github-cli:1": {},
16-
"ghcr.io/devcontainers-extra/features/pipx-package:1": {},
17-
"ghcr.io/devcontainers-extra/features/pre-commit:2": {},
1816
"ghcr.io/devcontainers/features/node:1": {},
1917
"ghcr.io/devcontainers/features/terraform:1": {
2018
"installTerraformDocs": true
@@ -35,6 +33,13 @@
3533
"bash": {
3634
"path": "/bin/bash"
3735
}
36+
},
37+
"[python]": {
38+
"editor.defaultFormatter": "charliermarsh.ruff",
39+
"editor.codeActionsOnSave": {
40+
"source.fixAll": "explicit",
41+
"source.organizeImports": "explicit"
42+
}
3843
}
3944
},
4045
"extensions": [
@@ -47,9 +52,7 @@
4752
"GitHub.vscode-pull-request-github",
4853
"hashicorp.terraform",
4954
"ms-azuretools.vscode-azureterraform",
50-
"ms-azuretools.vscode-bicep",
5155
"ms-azuretools.vscode-docker",
52-
"ms-dotnettools.csdevkit",
5356
"ms-python.debugpy",
5457
"ms-python.python",
5558
"ms-python.vscode-pylance",
@@ -63,14 +66,12 @@
6366
"ms-kubernetes-tools.vscode-kubernetes-tools",
6467
"github.vscode-github-actions",
6568
"bierner.markdown-mermaid",
66-
"ms-python.autopep8",
6769
"ms-azuretools.vscode-azurefunctions",
6870
"ms-azuretools.vscode-azureresourcegroups",
69-
"ms-python.black-formatter",
7071
"ms-azuretools.vscode-containers",
7172
"tamasfe.even-better-toml",
72-
"ms-python.flake8",
7373
"redhat.vscode-yaml",
74+
"ms-toolsai.vscode-ai",
7475
"GitHub.copilot@prerelease",
7576
"GitHub.copilot-chat@prerelease"
7677
]
@@ -86,10 +87,13 @@
8687
},
8788

8889
"onCreateCommand": {
89-
// "pip": "pip install -r requirements.txt",
90-
"apt": "sudo apt update && sudo apt install -y shellcheck",
90+
"setup-dev": "./setup-dev.sh --disable-venv",
91+
"apt": "sudo apt update && sudo apt install -y shellcheck jq unzip",
9192
"tflint": "curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash",
92-
"update-bashrc": "echo 'export PATH=\"${containerWorkspaceFolder}/scripts:$PATH\"' | sudo tee -a ~/.bashrc"
93+
"update-bashrc": "echo 'export PATH=\"${containerWorkspaceFolder}/scripts:$PATH\"' | sudo tee -a ~/.bashrc",
94+
"osmo-cli": "curl -fsSL https://raw.githubusercontent.com/NVIDIA/OSMO/refs/heads/main/install.sh | bash || true",
95+
"ngc-cli": "wget -qO /tmp/ngccli.zip https://ngc.nvidia.com/downloads/ngccli_linux.zip && sudo unzip -o /tmp/ngccli.zip -d /usr/local/bin && rm /tmp/ngccli.zip && sudo chmod u+x /usr/local/bin/ngc || true",
96+
"az-ml": "az extension add -n ml --yes || true"
9397
},
9498

9599
// DONT USE 'postCreateCommand', it ruins your global .gitconfig https://github.com/devcontainers/cli/issues/787

setup-dev.sh

Lines changed: 99 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,120 @@ set -euo pipefail
33

44
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55
VENV_DIR="${SCRIPT_DIR}/.venv"
6+
DISABLE_VENV=false
67

7-
echo "Setting up local development environment..."
8+
while [[ $# -gt 0 ]]; do
9+
case $1 in
10+
--disable-venv)
11+
DISABLE_VENV=true
12+
shift
13+
;;
14+
*)
15+
echo "Unknown option: $1" >&2
16+
exit 1
17+
;;
18+
esac
19+
done
820

9-
if command -v pyenv &> /dev/null; then
10-
PYTHON_VERSION="$(cat "${SCRIPT_DIR}/.python-version")"
11-
echo "Python version from .python-version: ${PYTHON_VERSION}"
12-
echo "Installing Python ${PYTHON_VERSION} via pyenv..."
13-
pyenv install -s "${PYTHON_VERSION}"
21+
# shellcheck source=deploy/002-setup/lib/common.sh
22+
source "${SCRIPT_DIR}/deploy/002-setup/lib/common.sh"
23+
24+
# Preamble: Recommend devcontainer for easier setup
25+
echo
26+
echo "💡 RECOMMENDED: Use the Dev Container for the best experience."
27+
echo
28+
echo "The devcontainer includes all tools pre-configured:"
29+
echo " • Azure CLI, Terraform, kubectl, helm, jq"
30+
echo " • Python with all dependencies"
31+
echo " • VS Code extensions for Terraform and Python"
32+
echo
33+
echo "To use:"
34+
echo " VS Code → Reopen in Container (F1 → Dev Containers: Reopen)"
35+
echo " Codespaces → Open in Codespace from GitHub"
36+
echo
37+
echo "If this script fails, the devcontainer is your fallback."
38+
echo
39+
40+
section "Tool Verification"
41+
42+
require_tools az terraform kubectl helm jq
43+
info "All required tools found"
44+
45+
section "Python Environment Setup"
46+
47+
PYTHON_VERSION="$(cat "${SCRIPT_DIR}/.python-version")"
48+
info "Target Python version: ${PYTHON_VERSION}"
49+
50+
if command -v pyenv &>/dev/null; then
51+
info "Installing Python ${PYTHON_VERSION} via pyenv..."
52+
pyenv install -s "${PYTHON_VERSION}"
53+
PYTHON_CMD="python"
54+
elif command -v python3 &>/dev/null; then
55+
warn "pyenv not found, using system python3"
56+
PYTHON_CMD="python3"
57+
else
58+
fatal "Neither pyenv nor python3 found. Please install Python 3.11+"
1459
fi
1560

16-
echo "Using pyenv Python $(python --version)"
61+
info "Using Python: $($PYTHON_CMD --version)"
1762

18-
if [[ ! -d "${VENV_DIR}" ]]; then
19-
echo "Creating virtual environment at ${VENV_DIR}..."
20-
python -m venv "${VENV_DIR}"
63+
if [[ "${DISABLE_VENV}" == "true" ]]; then
64+
info "Virtual environment disabled, installing packages directly..."
2165
else
22-
echo "Virtual environment already exists at ${VENV_DIR}"
66+
if [[ ! -d "${VENV_DIR}" ]]; then
67+
info "Creating virtual environment at ${VENV_DIR}..."
68+
$PYTHON_CMD -m venv "${VENV_DIR}"
69+
else
70+
info "Virtual environment already exists at ${VENV_DIR}"
71+
fi
72+
info "Activating virtual environment..."
73+
source "${VENV_DIR}/bin/activate"
2374
fi
2475

25-
echo "Activating virtual environment..."
26-
source "${VENV_DIR}/bin/activate"
76+
info "Upgrading pip..."
77+
pip install --upgrade pip --quiet
2778

28-
echo "Upgrading pip..."
29-
pip install --upgrade pip
79+
info "Installing root dependencies..."
80+
if ! pip install -r "${SCRIPT_DIR}/requirements.txt" --quiet 2>/dev/null; then
81+
warn "Some packages failed to install (expected on macOS for Linux-only packages)"
82+
fi
3083

31-
echo "Installing root dependencies..."
32-
pip install -r "${SCRIPT_DIR}/requirements.txt"
84+
info "Installing training dependencies..."
85+
if ! pip install -r "${SCRIPT_DIR}/src/training/requirements.txt" --quiet 2>/dev/null; then
86+
warn "Some training packages failed to install"
87+
fi
3388

34-
echo "Installing training dependencies..."
35-
pip install -r "${SCRIPT_DIR}/src/training/requirements.txt"
89+
section "IsaacLab Setup"
3690

37-
echo ""
38-
echo "Setting up IsaacLab for local development..."
3991
ISAACLAB_DIR="${SCRIPT_DIR}/external/IsaacLab"
4092

4193
if [[ -d "${ISAACLAB_DIR}" ]]; then
42-
echo "IsaacLab already cloned at ${ISAACLAB_DIR}"
43-
echo "To update, run: cd ${ISAACLAB_DIR} && git pull"
94+
info "IsaacLab already cloned at ${ISAACLAB_DIR}"
95+
info "To update, run: cd ${ISAACLAB_DIR} && git pull"
4496
else
45-
echo "Cloning IsaacLab for intellisense/Pylance support..."
46-
mkdir -p "${SCRIPT_DIR}/external"
47-
git clone https://github.com/isaac-sim/IsaacLab.git "${ISAACLAB_DIR}"
48-
echo "IsaacLab cloned successfully"
97+
info "Cloning IsaacLab for intellisense/Pylance support..."
98+
mkdir -p "${SCRIPT_DIR}/external"
99+
git clone https://github.com/isaac-sim/IsaacLab.git "${ISAACLAB_DIR}"
100+
info "IsaacLab cloned successfully"
49101
fi
50102

51-
echo ""
52-
echo "✓ Development environment setup complete!"
53-
echo ""
54-
echo "To activate the environment, run:"
55-
echo " source .venv/bin/activate"
56-
echo ""
57-
echo "Python path: ${VENV_DIR}/bin/python"
103+
section "Setup Complete"
104+
105+
echo
106+
echo "✅ Development environment setup complete!"
107+
echo
108+
if [[ "${DISABLE_VENV}" == "false" ]]; then
109+
warn "Run this command to activate the virtual environment:"
110+
echo
111+
echo " source .venv/bin/activate"
112+
echo
113+
fi
114+
echo "Next steps:"
115+
echo " 1. Run: source deploy/000-prerequisites/az-sub-init.sh"
116+
echo " 2. Configure: deploy/001-iac/terraform.tfvars"
117+
echo " 3. Deploy: cd deploy/001-iac && terraform init && terraform apply"
118+
echo
119+
echo "Documentation:"
120+
echo " - README.md - Quick start guide"
121+
echo " - deploy/README.md - Deployment overview"
122+
echo

0 commit comments

Comments
 (0)