refactor: update Makefile commands for improved readability and efficiency (#3596)

* chore(Makefile): redirect output of 'poetry install' and 'npm install' commands to /dev/null to reduce noise
chore(Makefile): redirect output of 'npm run build' command to /dev/null to improve build process efficiency
feat(Makefile): update build_frontend target to include copying built files to backend directory for deployment

* chore(Makefile): refactor lint target to depend on install_backend task for better dependency management
chore(Makefile): refactor frontend, frontendc, backend, build_and_run, build_and_install, and build targets to depend on setup_env task for consistent environment setup before execution

* chore(Makefile): update Makefile commands to use @ symbol for silent execution and improve readability

* chore(Makefile): update Makefile commands to use "@" to suppress command output and improve readability

* chore(Makefile): update run_cli target to include dependencies installation and frontend build steps for better clarity and consistency

* chore(Makefile): add command to delete empty directories in clean_python_cache target
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-08-28 15:45:56 -03:00 • committed by GitHub
commit 5d81e8dce6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,23 +63,24 @@ help: ## show this help message
install_backend: ## install the backend dependencies install_backend: ## install the backend dependencies
@echo 'Installing backend dependencies' @echo 'Installing backend dependencies'
@poetry install @poetry install > /dev/null 2>&1
install_frontend: ## install the frontend dependencies install_frontend: ## install the frontend dependencies
@echo 'Installing frontend dependencies' @echo 'Installing frontend dependencies'
cd src/frontend && npm install @cd src/frontend && npm install > /dev/null 2>&1
build_frontend: ## build the frontend static files build_frontend: ## build the frontend static files
cd src/frontend && CI='' npm run build @echo 'Building frontend static files'
rm -rf src/backend/base/langflow/frontend @cd src/frontend && CI='' npm run build > /dev/null 2>&1
cp -r src/frontend/build src/backend/base/langflow/frontend @rm -rf src/backend/base/langflow/frontend
@cp -r src/frontend/build src/backend/base/langflow/frontend
init: check_tools clean_python_cache clean_npm_cache ## initialize the project init: check_tools clean_python_cache clean_npm_cache ## initialize the project
make install_backend @make install_backend
make install_frontend @make install_frontend
make build_frontend @make build_frontend
@echo "$(GREEN)All requirements are installed.$(NC)" @echo "$(GREEN)All requirements are installed.$(NC)"
python -m langflow run @python -m langflow run
###################### ######################
# CLEAN PROJECT # CLEAN PROJECT
@ -91,6 +92,7 @@ clean_python_cache:
find . -type f -name '*.py[cod]' -exec rm -f {} + find . -type f -name '*.py[cod]' -exec rm -f {} +
find . -type f -name '*~' -exec rm -f {} + find . -type f -name '*~' -exec rm -f {} +
find . -type f -name '.*~' -exec rm -f {} + find . -type f -name '.*~' -exec rm -f {} +
find . -type d -empty -delete
@echo "$(GREEN)Python cache cleaned.$(NC)" @echo "$(GREEN)Python cache cleaned.$(NC)"
clean_npm_cache: clean_npm_cache:
@ -108,15 +110,15 @@ setup_poetry: ## install poetry using pipx
add: add:
@echo 'Adding dependencies' @echo 'Adding dependencies'
ifdef devel ifdef devel
cd src/backend/base && poetry add --group dev $(devel) @cd src/backend/base && poetry add --group dev $(devel)
endif endif
ifdef main ifdef main
poetry add $(main) @poetry add $(main)
endif endif
ifdef base ifdef base
cd src/backend/base && poetry add $(base) @cd src/backend/base && poetry add $(base)
endif endif
@ -172,37 +174,32 @@ fix_codespell: ## run codespell to fix spelling errors
poetry run codespell --toml pyproject.toml --write poetry run codespell --toml pyproject.toml --write
format: ## run code formatters format: ## run code formatters
poetry run ruff check . --fix @poetry run ruff check . --fix
poetry run ruff format . @poetry run ruff format .
cd src/frontend && npm run format @cd src/frontend && npm run format
lint: ## run linters lint: install_backend ## run linters
poetry run mypy --namespace-packages -p "langflow" @poetry run mypy --namespace-packages -p "langflow"
install_frontendci: install_frontendci:
cd src/frontend && npm ci @cd src/frontend && npm ci > /dev/null 2>&1
install_frontendc: install_frontendc:
cd src/frontend && rm -rf node_modules package-lock.json && npm install @cd src/frontend && rm -rf node_modules package-lock.json && npm install > /dev/null 2>&1
run_frontend: ## run the frontend run_frontend: ## run the frontend
@-kill -9 `lsof -t -i:3000` @-kill -9 `lsof -t -i:3000`
cd src/frontend && npm start @cd src/frontend && npm start
tests_frontend: ## run frontend tests tests_frontend: ## run frontend tests
ifeq ($(UI), true) ifeq ($(UI), true)
cd src/frontend && npx playwright test --ui --project=chromium @cd src/frontend && npx playwright test --ui --project=chromium
else else
cd src/frontend && npx playwright test --project=chromium @cd src/frontend && npx playwright test --project=chromium
endif endif
run_cli: run_cli: install_frontend install_backend build_frontend ## run the CLI
@echo 'Running the CLI' @echo 'Running the CLI'
@make install_frontend > /dev/null
@echo 'Install backend dependencies'
@make install_backend > /dev/null
@echo 'Building the frontend'
@make build_frontend > /dev/null
ifdef env ifdef env
@make start env=$(env) host=$(host) port=$(port) log_level=$(log_level) @make start env=$(env) host=$(host) port=$(port) log_level=$(log_level)
else else
@ -251,20 +248,15 @@ setup_devcontainer: ## set up the development container
setup_env: ## set up the environment setup_env: ## set up the environment
@sh ./scripts/setup/setup_env.sh @sh ./scripts/setup/setup_env.sh
frontend: ## run the frontend in development mode frontend: install_frontend ## run the frontend in development mode
make install_frontend
make run_frontend make run_frontend
frontendc: frontendc: install_frontendc
make install_frontendc
make run_frontend make run_frontend
backend: ## run the backend in development mode backend: setup_env install_backend ## run the backend in development mode
@echo 'Setting up the environment'
@make setup_env
make install_backend
@-kill -9 $$(lsof -t -i:7860) @-kill -9 $$(lsof -t -i:7860)
ifdef login ifdef login
@echo "Running backend autologin is $(login)"; @echo "Running backend autologin is $(login)";
@ -288,9 +280,7 @@ else
--workers $(workers) --workers $(workers)
endif endif
build_and_run: ## build the project and run it build_and_run: setup_env ## build the project and run it
@echo 'Removing dist folder'
@make setup_env
rm -rf dist rm -rf dist
rm -rf src/backend/base/dist rm -rf src/backend/base/dist
make build make build
@ -303,9 +293,7 @@ build_and_install: ## build the project and install it
rm -rf src/backend/base/dist rm -rf src/backend/base/dist
make build && poetry run pip install dist/*.whl && pip install src/backend/base/dist/*.whl --force-reinstall make build && poetry run pip install dist/*.whl && pip install src/backend/base/dist/*.whl --force-reinstall
build: ## build the frontend static files and package the project build: setup_env ## build the frontend static files and package the project
@echo 'Building the project'
@make setup_env
ifdef base ifdef base
make install_frontendci make install_frontendci
make build_frontend make build_frontend