File size: 4,259 Bytes
a554e78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# justfile β€” ML in Elixir project tasks
# Usage: just <recipe>
# Install just: mise use just (or brew install just / cargo install just)

set dotenv-load

# Default: show available recipes
default:
    @just --list

# ─── Elixir / Livebook ───────────────────────────────────────────

# Install all Elixir deps
setup:
    mise exec -- mix setup

# Update all deps
update:
    mise exec -- mix deps.update --all

# Compile the project
compile:
    mise exec -- mix compile

# Run tests
test:
    mise exec -- mix test

# Open Livebook editor (serves on :8080)
livebook:
    mise exec -- mix run --eval "Livebook.Config.set(:default_runtime, Livebook.Config.Runtime.default_standalone())" 2>/dev/null; \
    mise exec -- livebook server --port 8080

# Open the main template in Livebook
notebook:
    mise exec -- livebook server ml_e2e_template.livemd

# ─── Deploy: Hugging Face Spaces ─────────────────────────────────

# Deploy Livebook to HF Spaces
deploy-livebook space:
    cp ml_e2e_template.livemd hf_deploy/
    cd hf_deploy && bash deploy.sh {{space}}

# Deploy Gradio to HF Spaces
deploy-gradio space:
    cd gradio_hf_deploy && \
    git clone https://huggingface.co/spaces/{{space}} /tmp/gradio-deploy 2>/dev/null || true && \
    cp app.py requirements.txt README.md /tmp/gradio-deploy/ && \
    cd /tmp/gradio-deploy && \
    git add -A && git commit -m "Update" && git push

# Deploy marimo to HF Spaces
deploy-marimo space:
    cd marimo && \
    git clone https://huggingface.co/spaces/{{space}} /tmp/marimo-deploy 2>/dev/null || true && \
    cp ml_e2e_marimo.py Dockerfile requirements.txt README.md /tmp/marimo-deploy/ && \
    cd /tmp/marimo-deploy && \
    git add -A && git commit -m "Update" && git push

# ─── Python / marimo ─────────────────────────────────────────────

# Run marimo editor
marimo:
    pip install -q marimo transformers torch numpy scikit-learn matplotlib 2>/dev/null; \
    marimo edit marimo/ml_e2e_marimo.py

# Run marimo as app (no code)
marimo-app:
    pip install -q marimo transformers torch numpy scikit-learn matplotlib 2>/dev/null; \
    marimo run marimo/ml_e2e_marimo.py

# Run Gradio app locally
gradio:
    pip install -q -r gradio_hf_deploy/requirements.txt 2>/dev/null; \
    python gradio_hf_deploy/app.py

# ─── Validation ──────────────────────────────────────────────────

# Check all files exist
check:
    @echo "=== Files ==="
    @test -f ml_e2e_template.livemd          && echo "βœ… Livebook template"   || echo "❌ Livebook template"
    @test -f hf_deploy/Dockerfile            && echo "βœ… HF Deploy (Docker)"  || echo "❌ HF Deploy (Docker)"
    @test -f colab_kaggle/ml_e2e_python.ipynb && echo "βœ… Colab/Kaggle (.ipynb)" || echo "❌ Colab/Kaggle"
    @test -f gradio_hf_deploy/app.py         && echo "βœ… Gradio app"          || echo "❌ Gradio app"
    @test -f marimo/ml_e2e_marimo.py         && echo "βœ… Marimo notebook"     || echo "❌ Marimo notebook"
    @echo "=== Tools ==="
    @which elixir  >/dev/null 2>&1 && echo "βœ… elixir"  || echo "⚠️  elixir not found (run: mise install)"
    @which python3 >/dev/null 2>&1 && echo "βœ… python3" || echo "⚠️  python3 not found"
    @which just    >/dev/null 2>&1 && echo "βœ… just"    || echo "⚠️  just not found (run: mise use just)"
    @which git     >/dev/null 2>&1 && echo "βœ… git"     || echo "⚠️  git not found"

# Verify mix deps resolve
deps-check:
    mise exec -- mix deps.get --check-unused 2>&1 || true
    mise exec -- mix deps

# ─── Clean ───────────────────────────────────────────────────────

# Clean build artifacts
clean:
    mise exec -- mix clean
    rm -rf _build deps
    find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
    find . -name "*.pyc" -delete 2>/dev/null || true