|
1 | | -#!/usr/bin/env bash |
2 | | -# install_fastlanes_env.sh |
3 | | -# ───────────────────────────────────────────────────────────── |
4 | | -# Sets FASTLANES_DATA_DIR for: |
5 | | -# • this shell |
6 | | -# • every future shell (bash/zsh) |
7 | | -# • all GUI apps (via LaunchAgent) – e.g. CLion |
8 | | -# ───────────────────────────────────────────────────────────── |
9 | | - |
10 | | -set -euo pipefail |
11 | | - |
12 | | -# 0) Hard-coded canonical path to your FastLanes_Data clone |
13 | | -DATA_DIR="$HOME/CLionProjects/FastLanes_Data" |
14 | | -if [[ ! -d "$DATA_DIR" ]]; then |
15 | | - echo "❌ Expected FastLanes_Data at: $DATA_DIR" >&2 |
16 | | - echo " Clone or move the repo there, then rerun this installer." >&2 |
17 | | - exit 1 |
18 | | -fi |
19 | | - |
20 | | -# 1) Export for **this** shell so you can build immediately |
21 | | -export FASTLANES_DATA_DIR="$DATA_DIR" |
22 | | -echo "FASTLANES_DATA_DIR set for current shell → $FASTLANES_DATA_DIR" |
23 | | - |
24 | | -# 2) Install a silent helper into ~/.local/bin and source it from rc files |
25 | | -HELPER_DIR="$HOME/.local/bin" |
26 | | -HELPER_PATH="$HELPER_DIR/export_fastlanes_data_dir.sh" |
27 | | -mkdir -p "$HELPER_DIR" |
28 | | - |
29 | | -cat >"$HELPER_PATH" <<'EOSH' |
30 | | -#!/usr/bin/env bash |
31 | | -# silent helper – just export the var if not already |
32 | | -FASTLANES_DATA_DIR_DEFAULT="$HOME/CLionProjects/FastLanes_Data" |
33 | | -export FASTLANES_DATA_DIR="${FASTLANES_DATA_DIR:-$FASTLANES_DATA_DIR_DEFAULT}" |
34 | | -EOSH |
35 | | -chmod +x "$HELPER_PATH" |
36 | | - |
37 | | -add_source_line() { |
38 | | - local rcfile="$1" |
39 | | - local marker="# >>> FastLanes_Data export >>>" |
40 | | - local line="source \"$HELPER_PATH\" >/dev/null 2>&1" |
41 | | - if ! grep -Fq "$marker" "$rcfile" 2>/dev/null; then |
42 | | - printf "\n%s\n%s\n# <<< FastLanes_Data export <<<\n" "$marker" "$line" >>"$rcfile" |
43 | | - echo "✓ Added helper source to $rcfile" |
44 | | - fi |
45 | | -} |
46 | | - |
47 | | -# Pick the correct rc file |
48 | | -case "${SHELL##*/}" in |
49 | | - zsh) RC_FILE="$HOME/.zshrc" ;; |
50 | | - bash) RC_FILE="${HOME}/.bash_profile"; [[ -f "$HOME/.bashrc" ]] && RC_FILE="$HOME/.bashrc" ;; |
51 | | - *) RC_FILE="$HOME/.profile" ;; |
52 | | -esac |
53 | | -add_source_line "$RC_FILE" |
54 | | - |
55 | | -# 3) Create a LaunchAgent so GUI apps inherit the var at login |
56 | | -PLIST="$HOME/Library/LaunchAgents/com.fastlanes.setenv.plist" |
57 | | -cat >"$PLIST" <<EOF |
58 | | -<?xml version="1.0" encoding="UTF-8"?> |
59 | | -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
60 | | -<plist version="1.0"> |
61 | | -<dict> |
62 | | - <key>Label</key> <string>com.fastlanes.setenv</string> |
63 | | - <key>ProgramArguments</key> <array> |
64 | | - <string>launchctl</string> |
65 | | - <string>setenv</string> |
66 | | - <string>FASTLANES_DATA_DIR</string> |
67 | | - <string>$DATA_DIR</string> |
68 | | - </array> |
69 | | - <key>RunAtLoad</key> <true/> |
70 | | -</dict> |
71 | | -</plist> |
72 | | -EOF |
73 | | - |
74 | | -# Load (or reload) the agent right away |
75 | | -launchctl unload "$PLIST" 2>/dev/null || true |
76 | | -launchctl load "$PLIST" |
77 | | -echo "✓ LaunchAgent installed & loaded (GUI apps will now see FASTLANES_DATA_DIR)" |
78 | | - |
79 | | -echo -e "\n✅ Done. Log out and back in once (or reboot) so CLion started from the Dock inherits the variable." |
| 1 | +# Makefile for FastLanes Data workflows |
| 2 | + |
| 3 | +# Force all recipes to run under Bash (so "set -o pipefail" works) |
| 4 | +SHELL := /bin/bash |
| 5 | + |
| 6 | +PYTHON := python3 |
| 7 | +SCRIPT := public_bi_extract_schemas.py |
| 8 | +VENV_DIR := venv |
| 9 | +ENV_SCRIPT := export_fastlanes_data_dir.sh |
| 10 | +REFORMAT := reformat_csvs.py |
| 11 | +CSV_SIZE_REPORT := csv_size_report.py |
| 12 | + |
| 13 | +.PHONY: all env install get_public_bi_schemas reformat_csvs csv_size_report clean |
| 14 | + |
| 15 | +# Default: load env, create venv, and run schema extraction |
| 16 | +all: env install get_public_bi_schemas |
| 17 | + |
| 18 | +# Load FASTLANES_DATA_DIR and other env vars |
| 19 | +env: |
| 20 | + @echo "Loading environment variables..." |
| 21 | + . $(CURDIR)/$(ENV_SCRIPT) |
| 22 | + |
| 23 | +# Set up (if needed) and install into virtual environment |
| 24 | +install: |
| 25 | + @if [ ! -d $(VENV_DIR) ]; then \ |
| 26 | + echo "Creating virtual environment..."; \ |
| 27 | + $(PYTHON) -m venv $(VENV_DIR); \ |
| 28 | + fi |
| 29 | + @echo "Upgrading pip..." |
| 30 | + . $(VENV_DIR)/bin/activate && pip install --upgrade pip |
| 31 | + @echo "Installing required Python packages..." |
| 32 | + . $(VENV_DIR)/bin/activate && pip install pyyaml pandas |
| 33 | + @if [ -f requirements.txt ]; then \ |
| 34 | + echo "Installing dependencies from requirements.txt..."; \ |
| 35 | + . $(VENV_DIR)/bin/activate && pip install -r requirements.txt; \ |
| 36 | + fi |
| 37 | + |
| 38 | +# Run the BI schema extraction script |
| 39 | +get_public_bi_schemas: install env |
| 40 | + @echo "Extracting public BI schemas..." |
| 41 | + cd scripts && . ../$(VENV_DIR)/bin/activate && $(PYTHON) $(SCRIPT) |
| 42 | + |
| 43 | +# Re-format all CSV files under NextiaJD |
| 44 | +reformat_csvs: install env |
| 45 | + @echo "Re-formatting all CSV files under NextiaJD..." |
| 46 | + . $(VENV_DIR)/bin/activate && \ |
| 47 | + $(PYTHON) scripts/$(REFORMAT) $(FASTLANES_DATA_DIR)/NextiaJD |
| 48 | + |
| 49 | +# -------------------------------------------------------------------- |
| 50 | +# New target: run the CSV‐size report script and save to csv_sizes_report.csv |
| 51 | +csv_size_report: install env |
| 52 | + @echo "Generating CSV size report..." |
| 53 | + . $(VENV_DIR)/bin/activate && \ |
| 54 | + $(PYTHON) scripts/$(CSV_SIZE_REPORT) > csv_sizes_report.csv |
| 55 | + @echo "→ csv_sizes_report.csv created." |
| 56 | + |
| 57 | +# Clean up generated files and virtual environment |
| 58 | +clean: |
| 59 | + @echo "Cleaning up..." |
| 60 | + rm -rf $(VENV_DIR) public_bi_benchmark ../public_bi/tables csv_sizes_report.csv |
0 commit comments