-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
165 lines (122 loc) · 4.25 KB
/
Copy pathMakefile
File metadata and controls
165 lines (122 loc) · 4.25 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# -----------------------------
# Paths (relative, no hardcode)
# -----------------------------
SHELL := /bin/bash
VENV := . mathdbmongo/bin/activate &&
PY := $(VENV) python
PY3 := $(VENV) python3
BOOK_TEMPLATE := quarto_book
BOOK_BUILD := quarto_book_build
EXPORTED_NOTES_DIR := exported_notes
EXPORTED_NOTES_BUILD_DIR := $(EXPORTED_NOTES_DIR)/_build
DATABASE ?= MathV0
STREAMLIT_HOST ?= 127.0.0.1
STREAMLIT_PORT ?= 8501
ADVANCED_READER_HOST ?= 127.0.0.1
ADVANCED_READER_PORT ?= 8766
LOG_LEVEL ?= info
MONGO_AUTH_MODE ?= auto
MONGO_AUTO_START ?= 1
ADVANCED_READER_URL_HOST := $(if $(filter ::1,$(ADVANCED_READER_HOST)),[$(ADVANCED_READER_HOST)],$(ADVANCED_READER_HOST))
.PHONY: start mongo stop restart status run run-streamlit advanced-reader gui lint export grafo \
book-clean book-export book-preview book-render \
clean clean-all book-clean-artifacts clean-book cuaderno-install cuaderno-status clean-notes
RUNTIME_ARGS := --database "$(DATABASE)" \
--streamlit-host "$(STREAMLIT_HOST)" \
--streamlit-port "$(STREAMLIT_PORT)" \
--advanced-reader-host "$(ADVANCED_READER_HOST)" \
--advanced-reader-port "$(ADVANCED_READER_PORT)" \
--log-level "$(LOG_LEVEL)"
RUNTIME_CLI := mathdbmongo/bin/python -m mathmongo runtime
MONGO_ENSURE_ARGS := --mongo-auth-mode "$(MONGO_AUTH_MODE)" \
$(if $(filter 0,$(MONGO_AUTO_START)),--no-mongo-auto-start,)
start:
@$(RUNTIME_CLI) start $(RUNTIME_ARGS) $(MONGO_ENSURE_ARGS)
mongo:
@$(RUNTIME_CLI) mongo-ensure $(RUNTIME_ARGS) $(MONGO_ENSURE_ARGS)
stop:
@$(RUNTIME_CLI) stop $(RUNTIME_ARGS)
restart:
@$(RUNTIME_CLI) restart $(RUNTIME_ARGS) $(MONGO_ENSURE_ARGS)
status:
@$(RUNTIME_CLI) doctor $(RUNTIME_ARGS)
# -----------------------
# 🚀 Aplicación Principal
# -----------------------
run:
@$(RUNTIME_CLI) run $(RUNTIME_ARGS) $(MONGO_ENSURE_ARGS)
run-streamlit:
MONGODB_DB="$(DATABASE)" \
MATHMONGO_ADVANCED_READER_URL="http://$(ADVANCED_READER_URL_HOST):$(ADVANCED_READER_PORT)" \
mathdbmongo/bin/python -m streamlit run editor/editor_streamlit.py \
--server.address "$(STREAMLIT_HOST)" \
--server.port "$(STREAMLIT_PORT)"
advanced-reader:
mathdbmongo/bin/python -m mathmongo.advanced_reader \
--host "$(ADVANCED_READER_HOST)" \
--port "$(ADVANCED_READER_PORT)" \
--database "$(DATABASE)" \
--log-level "$(LOG_LEVEL)"
gui:
. mathdbmongo/bin/activate && python run_gui.py
# -----------------------
# 🧹 Lint y correcciones automáticas
# -----------------------
lint:
ruff check . --fix
# -----------------------
# 📤 Exportar desde Mongo a Quarto
# -----------------------
export:
$(PY) export/exportar_qmd_desde_mongo.py
# -----------------------
# 🔗 Grafo interactivo desde Mongo
# -----------------------
grafo:
$(PY) grafo_interactivo/generador/generar_grafo.py
# -----------------------
# 📚 Documentación Quarto
# -----------------------
book-clean:
rm -rf $(BOOK_BUILD)
book-export:
$(PY3) scripts/export_quarto_book.py --template $(BOOK_TEMPLATE) --output $(BOOK_BUILD) --force
book-preview:
cd $(BOOK_BUILD) && quarto preview
book-render:
cd $(BOOK_BUILD) && quarto render --to pdf
export-book:
$(PY3) scripts/export_quarto_book.py --output quarto_book_build --force
# -----------------------
# 🧼 Limpieza de archivos temporales
# -----------------------
clean:
find . -name "*.pyc" -delete
find . -name "__pycache__" -type d -exec rm -r {} +
rm -rf .ruff_cache/
# Limpieza extendida
clean-all: clean
rm -rf exportados/
rm -rf build/ dist/ *.egg-info
rm -rf .ipynb_checkpoints/
rm -rf $(BOOK_BUILD)/
book-clean-artifacts:
@test -d $(BOOK_BUILD) || (echo "No build dir: $(BOOK_BUILD)"; exit 0)
rm -rf $(BOOK_BUILD)/_book
find $(BOOK_BUILD) -name "*.html" -delete || true
clean-book: book-clean
book: book-clean book-export book-preview
book-html: book-clean book-export book-render
cuaderno-install:
python scripts/install_cuaderno_mode.py
cuaderno-status:
python scripts/install_cuaderno_mode.py --status
clean-notes:
@echo "🧹 Cleaning exported notes (keeping directories)..."
@if [ -d "$(EXPORTED_NOTES_DIR)" ]; then \
find "$(EXPORTED_NOTES_DIR)" -mindepth 1 -maxdepth 1 ! -name "_build" -exec rm -rf {} + ; \
fi
@if [ -d "$(EXPORTED_NOTES_BUILD_DIR)" ]; then \
rm -rf "$(EXPORTED_NOTES_BUILD_DIR)"/* ; \
fi
@echo "✅ exported_notes cleaned (directories preserved)"