ref: improving development environment and instructions (#5180)
* improving development environment and instructions * minor edits as requested * fix typo in DEVELOPMENT.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
ba31d436c4
commit
d1821cb466
8 changed files with 391 additions and 157 deletions
37
Makefile
37
Makefile
|
|
@ -1,4 +1,4 @@
|
|||
.PHONY: all init format lint build build_frontend install_frontend run_frontend run_backend dev help tests coverage clean_python_cache clean_npm_cache clean_all
|
||||
.PHONY: all init format_backend format_frontend format lint build build_frontend install_frontend run_frontend run_backend dev help tests coverage clean_python_cache clean_npm_cache clean_all
|
||||
|
||||
# Configurations
|
||||
VERSION=$(shell grep "^version" pyproject.toml | sed 's/.*\"\(.*\)\"$$/\1/')
|
||||
|
|
@ -27,6 +27,12 @@ all: help
|
|||
# UTILITIES
|
||||
######################
|
||||
|
||||
# Some directories may be mount points as in devcontainer, so we need to clear their
|
||||
# contents rather than remove the entire directory. But we must also be mindful that
|
||||
# we are not running in a devcontainer, so need to ensure the directories exist.
|
||||
# See https://code.visualstudio.com/remote/advancedcontainers/improve-performance
|
||||
CLEAR_DIRS = $(foreach dir,$1,$(shell mkdir -p $(dir) && find $(dir) -mindepth 1 -delete))
|
||||
|
||||
# increment the patch version of the current package
|
||||
patch: ## bump the version in langflow and langflow-base
|
||||
@echo 'Patching the version'
|
||||
|
|
@ -68,8 +74,8 @@ install_frontend: ## install the frontend dependencies
|
|||
build_frontend: ## build the frontend static files
|
||||
@echo 'Building frontend static files'
|
||||
@cd src/frontend && CI='' npm run build > /dev/null 2>&1
|
||||
@rm -rf src/backend/base/langflow/frontend
|
||||
@cp -r src/frontend/build src/backend/base/langflow/frontend
|
||||
$(call CLEAR_DIRS,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
|
||||
@make install_backend
|
||||
|
|
@ -88,13 +94,14 @@ clean_python_cache:
|
|||
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 d -empty -delete
|
||||
$(call CLEAR_DIRS,.mypy_cache )
|
||||
@echo "$(GREEN)Python cache cleaned.$(NC)"
|
||||
|
||||
clean_npm_cache:
|
||||
@echo "Cleaning npm cache..."
|
||||
cd src/frontend && npm cache clean --force
|
||||
rm -rf src/frontend/node_modules src/frontend/build src/backend/base/langflow/frontend src/frontend/package-lock.json
|
||||
$(call CLEAR_DIRS,src/frontend/node_modules src/frontend/build src/backend/base/langflow/frontend)
|
||||
rm -f src/frontend/package-lock.json
|
||||
@echo "$(GREEN)NPM cache and frontend directories cleaned.$(NC)"
|
||||
|
||||
clean_all: clean_python_cache clean_npm_cache # clean all caches and temporary directories
|
||||
|
|
@ -179,11 +186,15 @@ fix_codespell: ## run codespell to fix spelling errors
|
|||
@poetry install --with spelling
|
||||
poetry run codespell --toml pyproject.toml --write
|
||||
|
||||
format: ## run code formatters
|
||||
@uv run ruff check . --fix
|
||||
format_backend: ## backend code formatters
|
||||
@uv run ruff check . --fix --ignore EXE002
|
||||
@uv run ruff format . --config pyproject.toml
|
||||
|
||||
format_frontend: ## frontend code formatters
|
||||
@cd src/frontend && npm run format
|
||||
|
||||
format: format_backend format_frontend ## run code formatters
|
||||
|
||||
unsafe_fix:
|
||||
@uv run ruff check . --fix --unsafe-fixes
|
||||
|
||||
|
|
@ -194,11 +205,11 @@ install_frontendci:
|
|||
@cd src/frontend && npm ci > /dev/null 2>&1
|
||||
|
||||
install_frontendc:
|
||||
@cd src/frontend && rm -rf node_modules package-lock.json && npm install > /dev/null 2>&1
|
||||
@cd src/frontend && $(call CLEAR_DIRS,node_modules) && rm -f package-lock.json && npm install > /dev/null 2>&1
|
||||
|
||||
run_frontend: ## run the frontend
|
||||
@-kill -9 `lsof -t -i:3000`
|
||||
@cd src/frontend && npm start
|
||||
@cd src/frontend && npm start $(if $(FRONTEND_START_FLAGS),-- $(FRONTEND_START_FLAGS))
|
||||
|
||||
tests_frontend: ## run frontend tests
|
||||
ifeq ($(UI), true)
|
||||
|
|
@ -272,16 +283,14 @@ else
|
|||
endif
|
||||
|
||||
build_and_run: setup_env ## build the project and run it
|
||||
rm -rf dist
|
||||
rm -rf src/backend/base/dist
|
||||
$(call CLEAR_DIRS,dist src/backend/base/dist)
|
||||
make build
|
||||
uv run pip install dist/*.tar.gz
|
||||
uv run langflow run
|
||||
|
||||
build_and_install: ## build the project and install it
|
||||
@echo 'Removing dist folder'
|
||||
rm -rf dist
|
||||
rm -rf src/backend/base/dist
|
||||
$(call CLEAR_DIRS,dist src/backend/base/dist)
|
||||
make build && uv run pip install dist/*.whl && pip install src/backend/base/dist/*.whl --force-reinstall
|
||||
|
||||
build: setup_env ## build the frontend static files and package the project
|
||||
|
|
@ -300,7 +309,7 @@ endif
|
|||
|
||||
build_langflow_base:
|
||||
cd src/backend/base && uv build $(args)
|
||||
rm -rf src/backend/base/langflow/frontend
|
||||
$(call CLEAR_DIRS,src/backend/base/langflow/frontend)
|
||||
|
||||
build_langflow_backup:
|
||||
uv lock && uv build
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue