mirror of
https://github.com/PR0M3TH3AN/python_charts.git
synced 2026-10-27 08:50:39 +00:00
Update .gitignore, enhance repo-context documentation, and refine startup script
- Add `repo-context.txt` to .gitignore to prevent tracking of generated context files. - Expand documentation in `repo-context.txt` to include detailed usage instructions, quickstart guide, and repository structure for the lagged oil-unemployment chart project. - Refine `startup.sh` script comments for clarity on its purpose and usage.
This commit is contained in:
1 parent
8797ef1d04
commit
3c097cc847
3 files changed
+171
-26
No files matched your search
+33
-25
@@ -1,14 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# -------------------------------------------------------------------
|
||||
# startup.sh — prepare Python env, ensure dependencies, FRED data,
|
||||
# and run a command inside the venv
|
||||
# startup.sh — prepare Python env, ensure deps & data, then run.
|
||||
# Usage:
|
||||
# ./startup.sh [command…]
|
||||
# Automatically:
|
||||
# - Upgrades pip & setuptools (ensuring distutils on Python 3.12+)
|
||||
# - Creates venv if missing
|
||||
# - Installs requirements
|
||||
# - Downloads data/fred.db if missing
|
||||
# ./startup.sh [options] # passes options to default plot script
|
||||
# ./startup.sh [script or cmd] # runs specified script/command
|
||||
# Examples:
|
||||
# ./startup.sh --offset 12 --end 2025-05-31 --extend-years 5
|
||||
# ./startup.sh pytest -q
|
||||
# -------------------------------------------------------------------
|
||||
set -euo pipefail
|
||||
|
||||
@@ -16,46 +14,56 @@ VENV_DIR="venv"
|
||||
REQ_FILE="requirements.txt"
|
||||
WHEELHOUSE="wheelhouse"
|
||||
DATA_DB="data/fred.db"
|
||||
PYTHON="$VENV_DIR/bin/python"
|
||||
DEFAULT_SCRIPT="scripts/lagged_oil_unrate_chart_styled.py"
|
||||
|
||||
# 1) Create or reuse venv
|
||||
if [[ ! -d "$VENV_DIR" ]]; then
|
||||
echo "🔧 Creating virtual-env…"
|
||||
python3 -m venv "$VENV_DIR"
|
||||
fi
|
||||
# Activate
|
||||
|
||||
# 2) Activate venv
|
||||
# shellcheck disable=SC1090
|
||||
source "$VENV_DIR/bin/activate"
|
||||
|
||||
# 2) Upgrade pip & setuptools (to provide distutils on Py3.12+)
|
||||
# 3) Upgrade pip & setuptools
|
||||
echo "🛠 Upgrading pip & setuptools…"
|
||||
pip install --upgrade pip setuptools
|
||||
$PYTHON -m pip install --upgrade pip setuptools
|
||||
|
||||
# 3) Install project dependencies
|
||||
# 4) Install dependencies
|
||||
PIP_OPTS=(install --upgrade --no-input)
|
||||
if [[ -d "$WHEELHOUSE" ]]; then
|
||||
echo "📦 Installing from wheelhouse…"
|
||||
pip "${PIP_OPTS[@]}" --no-index --find-links="$WHEELHOUSE" -r "$REQ_FILE" \
|
||||
|| { echo "⚠️ Wheelhouse failed—falling back to PyPI…"; \
|
||||
pip "${PIP_OPTS[@]}" -r "$REQ_FILE"; }
|
||||
$PYTHON -m pip "${PIP_OPTS[@]}" --no-index --find-links="$WHEELHOUSE" -r "$REQ_FILE" \
|
||||
|| { echo "⚠️ Wheelhouse failed—falling back…"; \
|
||||
$PYTHON -m pip "${PIP_OPTS[@]}" -r "$REQ_FILE"; }
|
||||
else
|
||||
echo "🌐 Installing from PyPI…"
|
||||
pip "${PIP_OPTS[@]}" -r "$REQ_FILE"
|
||||
$PYTHON -m pip "${PIP_OPTS[@]}" -r "$REQ_FILE"
|
||||
fi
|
||||
|
||||
echo "✅ Virtual-env ready ($(python -V))"
|
||||
echo "✅ Virtual-env ready ($($PYTHON -V))"
|
||||
|
||||
# 4) Ensure data/fred.db exists
|
||||
# 5) Ensure data exists
|
||||
if [[ ! -f "$DATA_DB" ]]; then
|
||||
echo "🔄 $DATA_DB not found—downloading FRED series…"
|
||||
python scripts/refresh_data.py
|
||||
echo "🔄 Data not found—downloading FRED series…"
|
||||
$PYTHON scripts/refresh_data.py
|
||||
fi
|
||||
|
||||
# 5) Decide what to run
|
||||
if [[ $# -gt 0 ]]; then
|
||||
CMD=("$@")
|
||||
# 6) Build command
|
||||
if [[ $# -eq 0 ]]; then
|
||||
CMD=("$PYTHON" "$DEFAULT_SCRIPT" --offset 18)
|
||||
elif [[ "$1" == --* ]]; then
|
||||
CMD=("$PYTHON" "$DEFAULT_SCRIPT" "$@")
|
||||
else
|
||||
CMD=(python scripts/lagged_oil_unrate_chart_styled.py --offset 18)
|
||||
if [[ -f "$1" || "$1" == *.py ]]; then
|
||||
CMD=("$PYTHON" "$@")
|
||||
else
|
||||
CMD=("$@")
|
||||
fi
|
||||
fi
|
||||
|
||||
# 7) Execute
|
||||
echo "🚀 Executing: ${CMD[*]}"
|
||||
exec "${CMD[@]}"
|
||||
exec "${CMD[@]}"
|
||||
Reference in new issue
Block a user