-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
182 lines (146 loc) · 10.2 KB
/
Copy pathMakefile
File metadata and controls
182 lines (146 loc) · 10.2 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Show help, place this first so it runs with just `make`
help:
@printf "\nCommands:\n"
@printf "\033[32mbuild\033[0m build the Docker image\n"
@printf "\033[32mrun\033[0m run the Docker container\n"
@printf "\033[32mliveness\033[0m check if the services are alive\n"
@printf "\033[32mservices\033[0m run services using Docker\n"
@printf "\033[32mservices-stop\033[0m stop the running Docker services\n"
@printf "\033[32mservices-mongo\033[0m run services with MongoDB using Docker\n"
@printf "\033[32mservices-stop-mongo\033[0m stop MongoDB services and remove attached volumes\n"
@printf "\033[32mservices-kafka\033[0m run services with Kafka using Docker\n"
@printf "\033[32mservices-stop-kafka\033[0m stop Kafka services and remove attached volumes\n"
@printf "\033[32mservices-mofka\033[0m run services with Mofka using Docker\n"
@printf "\033[32mservices-stop-mofka\033[0m stop Mofka services and remove attached volumes\n"
@printf "\033[32mservices-rabbitmq\033[0m run services with RabbitMQ using Docker\n"
@printf "\033[32mservices-stop-rabbitmq\033[0m stop RabbitMQ services and remove attached volumes\n"
@printf "\033[32mtests\033[0m run unit tests with pytest\n"
@printf "\033[32mtests-offline\033[0m run offline-safe tests with pytest\n"
@printf "\033[32mtests-in-container\033[0m run unit tests with pytest inside Flowcept's container\n"
@printf "\033[32mtests-in-container-mongo\033[0m run unit tests inside container with MongoDB\n"
@printf "\033[32mtests-in-container-kafka\033[0m run unit tests inside container with Kafka and MongoDB\n"
@printf "\033[32mtests-in-container-rabbitmq\033[0m run unit tests inside container with RabbitMQ and MongoDB\n"
@printf "\033[32mtests-notebooks\033[0m test the notebooks using pytest\n"
@printf "\033[32mclean\033[0m remove cache directories and Sphinx build output\n"
@printf "\033[32mdocs\033[0m build HTML documentation using Sphinx\n"
@printf "\033[32mwebservice\033[0m start the Flowcept webservice (REST API + web UI)\n"
@printf "\033[32mui\033[0m kill old processes, start FastAPI + React frontend services\n"
@printf "\033[32mui-install\033[0m install web UI dependencies (npm ci)\n"
@printf "\033[32mui-dev\033[0m run the React frontend service (proxies /api to :8008)\n"
@printf "\033[32mui-build\033[0m build the web UI into src/flowcept/webservice/ui_build\n"
@printf "\033[32mui-checks\033[0m typecheck the web UI\n"
@printf "\033[32mui-test\033[0m run web UI unit tests (vitest)\n"
@printf "\033[32mui-e2e\033[0m run web UI end-to-end tests (playwright)\n"
@printf "\033[32mchecks\033[0m run ruff linter and formatter checks\n"
@printf "\033[32mreformat\033[0m run ruff linter and formatter\n"
@printf "\033[32mcompile-rules\033[0m compile central rules files for all coding assistants\n"
# Run linter and formatter checks using ruff
checks:
ruff check src
ruff format --check src
.PHONY: compile-rules
compile-rules:
python scripts/compile_rules.py
.PHONY: ui-install ui-dev ui-build ui-checks ui-test ui-e2e ui
ui-install:
npm ci --prefix ui --no-audit --no-fund
ui-dev:
npm run dev --prefix ui
ui-build:
npm run build --prefix ui
ui-checks:
npm run lint --prefix ui
ui-test:
npm test --prefix ui
ui-e2e:
cd ui && npx playwright test
ui:
FLOWCEPT_SETTINGS_PATH=$(or $(FLOWCEPT_SETTINGS_PATH),$(PWD)/agent_sandbox/settings.yaml) PYTHONPATH=src python -m flowcept.cli --start --ui
reformat:
ruff check src --fix --unsafe-fixes
ruff format src
# Remove cache directories and Sphinx build output
clean:
@sh -c 'rm -rf .ruff_cache .pytest_cache mnist_data tensorboard_events 2>/dev/null || true'
@sh -c 'rm -f docs_dump_tasks_* dump_test.json 2>/dev/null || true'
@find . -type d -name "*flowcept_lmdb*" -exec sh -c 'rm -rf "$$@" 2>/dev/null || true' sh {} +
@find . -type f -name "*.log" -exec sh -c 'rm -f "$$@" 2>/dev/null || true' sh {} +
@find . -type f -name "*.pth" -exec sh -c 'rm -f "$$@" 2>/dev/null || true' sh {} +
@find . -type f -name "mlflow.db" -exec sh -c 'rm -f "$$@" 2>/dev/null || true' sh {} +
@find . -type d -name "mlruns" -exec sh -c 'rm -rf "$$@" 2>/dev/null || true' sh {} +
@find . -type d -name "__pycache__" -exec sh -c 'rm -rf "$$@" 2>/dev/null || true' sh {} +
@find . -type d -name "*tfevents*" -exec sh -c 'rm -rf "$$@" 2>/dev/null || true' sh {} +
@find . -type d -name "*output_data*" -exec sh -c 'rm -rf "$$@" 2>/dev/null || true' sh {} +
@find . -type f -name "*nohup*" -exec sh -c 'rm -f "$$@" 2>/dev/null || true' sh {} +
@sh -c 'sphinx-build -M clean docs docs/_build > /dev/null 2>&1 || true'
@sh -c 'rm -f docs/generated/* 2>/dev/null || true'
@sh -c 'rm -f docs/_build/* 2>/dev/null || true'
# Build the HTML documentation using Sphinx
.PHONY: docs
docs:
PYTHONPATH=src python docs/openapi/scripts/generate_openapi.py
sphinx-build -M html docs docs/_build
@echo "Docs built: open docs/_build/html/index.html"
.PHONY: webservice
webservice:
FLOWCEPT_SETTINGS_PATH=$(or $(FLOWCEPT_SETTINGS_PATH),$(PWD)/agent_sandbox/settings.yaml) PYTHONPATH=src python -m flowcept.cli --start --webservice
# Run services using Docker
services:
docker compose --file deployment/compose.yml up --detach
# Stop the running Docker services and remove volumes attached to containers
services-stop:
docker compose --file deployment/compose.yml down --volumes
# Run services using Docker
services-mongo:
docker compose --file deployment/compose-mongo.yml up --detach
services-stop-mongo:
docker compose --file deployment/compose-mongo.yml down --volumes
# Build a new Docker image for Flowcept
build:
bash deployment/build-image.sh
# To use run, you must run make services first.
run:
docker run --rm -v $(shell pwd):/flowcept -e KVDB_HOST=flowcept_redis -e MQ_HOST=flowcept_redis -e MONGO_HOST=flowcept_mongo --network flowcept_default -it flowcept
tests-in-container-mongo:
docker run --rm -v $(shell pwd):/flowcept -e KVDB_HOST=flowcept_redis -e MQ_HOST=flowcept_redis -e MONGO_HOST=flowcept_mongo -e MONGO_ENABLED=true -e LMDB_ENABLED=false --network flowcept_default flowcept /bin/bash -lc '/opt/conda/envs/flowcept/bin/flowcept --init-settings --full -y && /opt/conda/envs/flowcept/bin/flowcept --config-profile full-online -y && /opt/conda/envs/flowcept/bin/pytest tests --timeout=600 --ignore=tests/adapters/test_tensorboard.py --ignore=tests/instrumentation_tests/ml_tests --ignore=tests/misc_tests/telemetry_test.py -k "not test_decorated_function_timed"'
tests-in-container:
docker run --rm -v $(shell pwd):/flowcept -e KVDB_HOST=flowcept_redis -e MQ_HOST=flowcept_redis -e MONGO_ENABLED=false -e LMDB_ENABLED=true --network flowcept_default flowcept /bin/bash -lc '/opt/conda/envs/flowcept/bin/flowcept --init-settings --full -y && /opt/conda/envs/flowcept/bin/flowcept --config-profile full-online -y && /opt/conda/envs/flowcept/bin/pytest tests --timeout=600 --ignore=tests/adapters/test_tensorboard.py --ignore=tests/instrumentation_tests/ml_tests --ignore=tests/misc_tests/telemetry_test.py -k "not test_decorated_function_timed"'
tests-in-container-kafka:
docker run --rm -v $(shell pwd):/flowcept -e KVDB_HOST=flowcept_redis -e MQ_HOST=kafka -e MONGO_HOST=flowcept_mongo -e MQ_PORT=29092 -e MQ_TYPE=kafka -e MONGO_ENABLED=true -e LMDB_ENABLED=false --network flowcept_default flowcept /bin/bash -lc '/opt/conda/envs/flowcept/bin/flowcept --init-settings --full -y && /opt/conda/envs/flowcept/bin/flowcept --config-profile full-online -y && /opt/conda/envs/flowcept/bin/pytest tests --timeout=600 --ignore=tests/adapters/test_tensorboard.py --ignore=tests/instrumentation_tests/ml_tests --ignore=tests/misc_tests/telemetry_test.py -k "not test_decorated_function_timed"'
# This command can be removed once we have our CLI
liveness:
python -c 'from flowcept import Flowcept; print(Flowcept.services_alive())'
dev_agent:
mcp dev src/flowcept/flowceptor/adapters/agents/flowcept_agent.py
install_dev_agent: # Run this to fix python env problems in the MCP studio env
mcp install src/flowcept/flowceptor/adapters/agents/flowcept_agent.py
# Run services with Kafka using Docker
services-kafka:
docker compose --file deployment/compose-kafka.yml up --detach
# Stop Kafka services and remove attached volumes
services-stop-kafka:
docker compose --file deployment/compose-kafka.yml down --volumes
# Run services with Mofka using Docker
services-mofka:
docker compose --file deployment/compose-mofka.yml up --detach
# Stop Mofka services and remove attached volumes
services-stop-mofka:
docker compose --file deployment/compose-mofka.yml down --volumes
# Run services with RabbitMQ using Docker
services-rabbitmq:
docker compose --file deployment/compose-rabbitmq.yml up --detach
# Stop RabbitMQ services and remove attached volumes
services-stop-rabbitmq:
docker compose --file deployment/compose-rabbitmq.yml down --volumes
tests-in-container-rabbitmq:
docker run --rm -v $(shell pwd):/flowcept -e KVDB_HOST=flowcept_redis -e MQ_HOST=flowcept_rabbitmq -e MQ_PORT=5672 -e MQ_TYPE=rabbitmq -e MONGO_HOST=flowcept_mongo -e MONGO_ENABLED=true -e LMDB_ENABLED=false --network flowcept_default flowcept /bin/bash -lc '/opt/conda/envs/flowcept/bin/flowcept --init-settings --full -y && /opt/conda/envs/flowcept/bin/flowcept --config-profile full-online -y && /opt/conda/envs/flowcept/bin/pytest tests --timeout=600 --ignore=tests/adapters/test_tensorboard.py --ignore=tests/instrumentation_tests/ml_tests --ignore=tests/misc_tests/telemetry_test.py -k "not test_decorated_function_timed"'
# Run unit tests using pytest
.PHONY: tests
tests:
pytest tests --timeout=600 --ignore=tests/adapters/test_tensorboard.py
.PHONY: tests-offline
tests-offline:
pytest -m safeoffline tests --ignore=tests/adapters --ignore=tests/api --ignore=tests/doc_db_inserter --ignore=tests/misc_tests/singleton_test.py
.PHONY: tests-notebooks
tests-notebooks:
pytest --nbmake "notebooks/" --nbmake-timeout=600 --ignore=notebooks/dask_from_CLI.ipynb --ignore=notebooks/tensorboard.ipynb