-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
159 lines (131 loc) · 5.16 KB
/
Makefile
File metadata and controls
159 lines (131 loc) · 5.16 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
POETRY_PYTHON ?= $(if $(pythonLocation),$(pythonLocation)/bin/python,python3)
SRC_DIRS = statgpt scripts tests
MYPY_DIRS = statgpt scripts
-include .env
export
# AI DIAL SDK: pydantic v2 mode
export PYDANTIC_V2=True
remove_venv:
poetry env remove --all || true
$(POETRY_PYTHON) -m venv .venv
init_venv:
poetry env use .venv/bin/python
install_dev: init_venv
poetry install -E cli -E beta-mcp --with dev
install_all: init_venv
poetry install -E cli -E beta-mcp --with dev,experiments
format: install_dev
poetry run autoflake ${SRC_DIRS}
poetry run black ${SRC_DIRS}
poetry run isort ${SRC_DIRS}
mypy: install_dev
poetry run mypy --show-error-codes ${MYPY_DIRS} ${ARGS}
lint: install_dev
poetry check --lock
poetry run flake8 ${SRC_DIRS}
poetry run black ${SRC_DIRS} --check
poetry run isort ${SRC_DIRS} --check-only --diff
poetry run autoflake ${SRC_DIRS} --check
# for now we only check data abstractions and services packages
poetry run mypy --show-error-codes ${MYPY_DIRS}
poetry run python scripts/check_imports.py
statgpt_cli: install_dev
poetry run python -m statgpt.cli $(ARGS)
statgpt_admin:
poetry run python -m statgpt.admin.app $(ARGS)
statgpt_fix_statuses:
poetry run python -m statgpt.admin.fix_statuses
statgpt_auto_update:
poetry run python -m statgpt.admin.auto_update
statgpt_app:
poetry run python -m statgpt.app.app $(ARGS)
install_pre_commit_hooks:
poetry run pre-commit install
db_migrate:
poetry run alembic -c alembic.ini upgrade head
db_downgrade:
poetry run alembic -c alembic.ini downgrade -1
db_autogenerate:
poetry run alembic -c alembic.ini revision --autogenerate -m "$(MESSAGE)"
test_db_migrate: export PGVECTOR_HOST=$(TEST_DATABASE_HOST)
test_db_migrate: export PGVECTOR_PORT=$(TEST_DATABASE_PORT)
test_db_migrate: export PGVECTOR_DATABASE=$(TEST_DATABASE)
test_db_migrate: export ELASTIC_CONNECTION_STRING=$(TEST_ELASTIC_CONNECTION_STRING)
test_db_migrate: install_dev
poetry run alembic -c alembic.ini upgrade head
test_unit: export PGVECTOR_HOST=$(TEST_DATABASE_HOST)
test_unit: export PGVECTOR_PORT=$(TEST_DATABASE_PORT)
test_unit: export PGVECTOR_DATABASE=$(TEST_DATABASE)
test_unit: export ELASTIC_CONNECTION_STRING=$(TEST_ELASTIC_CONNECTION_STRING)
test_unit: install_dev
poetry run pytest tests/unit --junitxml=reports/tests-unit.xml
test_integration: export EMBEDDING_DEFAULT_MODEL=text-embedding-3-large
test_integration: export PGVECTOR_HOST=$(TEST_DATABASE_HOST)
test_integration: export PGVECTOR_PORT=$(TEST_DATABASE_PORT)
test_integration: export PGVECTOR_DATABASE=$(TEST_DATABASE)
test_integration: export ELASTIC_CONNECTION_STRING=$(TEST_ELASTIC_CONNECTION_STRING)
test_integration: test_db_migrate
poetry run pytest tests/integration --junitxml=reports/tests-int.xml
test: test_unit test_integration
# Localization commands for dataset formatters
# Check if GNU gettext tools are installed
check_gettext:
ifeq ($(OS),Windows_NT)
@where xgettext >nul 2>&1 || ( \
echo Error: xgettext not found. GNU gettext tools are required for localization. & \
echo. & \
echo Installation instructions: & \
echo MacOS: brew install gettext & \
echo Linux/WSL: sudo apt install gettext & \
echo Windows: choco install gettext & \
echo. & \
echo See README.md for more details. & \
exit /b 1 \
)
@where msgmerge >nul 2>&1 || (echo Error: msgmerge not found. Please install GNU gettext tools. & exit /b 1)
@where msgfmt >nul 2>&1 || (echo Error: msgfmt not found. Please install GNU gettext tools. & exit /b 1)
else
@command -v xgettext >/dev/null 2>&1 || { \
echo "Error: xgettext not found. GNU gettext tools are required for localization."; \
echo ""; \
echo "Installation instructions:"; \
echo " MacOS: brew install gettext"; \
echo " Linux/WSL: sudo apt install gettext"; \
echo " Windows: choco install gettext"; \
echo ""; \
echo "See README.md for more details."; \
exit 1; \
}
@command -v msgmerge >/dev/null 2>&1 || { \
echo "Error: msgmerge not found. Please install GNU gettext tools."; \
exit 1; \
}
@command -v msgfmt >/dev/null 2>&1 || { \
echo "Error: msgfmt not found. Please install GNU gettext tools."; \
exit 1; \
}
endif
extract_messages: check_gettext
@echo "Extracting translatable strings from formatters..."
@cd statgpt/app/utils/formatters && \
xgettext -d dataset -o locales/dataset.pot \
--language=Python \
--keyword=_ \
--from-code=UTF-8 \
base.py dataset_base.py dataset_simple.py dataset_detailed.py datasets_list_formatter.py citation.py \
dataset_query.py dataset_availablity_query.py
update_messages: check_gettext
@echo "Updating .po files from template..."
@cd statgpt/app/utils/formatters/locales && \
msgmerge --update en/LC_MESSAGES/dataset.po dataset.pot && \
msgmerge --update uk/LC_MESSAGES/dataset.po dataset.pot
compile_messages: check_gettext
@echo "Compiling .po files to .mo files..."
@cd statgpt/app/utils/formatters/locales && \
msgfmt -o en/LC_MESSAGES/dataset.mo en/LC_MESSAGES/dataset.po && \
msgfmt -o uk/LC_MESSAGES/dataset.mo uk/LC_MESSAGES/dataset.po
# Convenience command to compile messages after changes
locales: compile_messages
# Utility to generate UUIDs
generate_uuid:
python -c "from uuid import uuid4; print(uuid4())"