Skip to content

Commit

Permalink
Improve makefile [edited] (#2141)
Browse files Browse the repository at this point in the history
* ignore sqlite tmp files

* update many dependencies to be optional

* improve makefile help messagem

* chore: Update langflow-base dependency to use local path for development

* change postgres to mandatory dependency

* improve makefile readability

* Revert update many dependencies to be optional

This reverts commit 8078056.

---------

Co-authored-by: ogabrielluiz <gabriel@langflow.org>
  • Loading branch information
italojohnny and ogabrielluiz authored Jun 13, 2024
1 parent b72ee8f commit 5ce1192
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ coverage.xml
local_settings.py
db.sqlite3
db.sqlite3-journal
*.db-shm
*.db-wal

# Flask stuff:
instance/
Expand Down
75 changes: 51 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ open_browser ?= true
path = src/backend/base/langflow/frontend
workers ?= 1


codespell:
@poetry install --with spelling
poetry run codespell --toml pyproject.toml


fix_codespell:
@poetry install --with spelling
poetry run codespell --toml pyproject.toml --write


setup_poetry:
pipx install poetry


add:
@echo 'Adding dependencies'
ifdef devel
Expand All @@ -34,52 +38,62 @@ ifdef base
cd src/backend/base && poetry add $(base)
endif


init:
@echo 'Installing backend dependencies'
make install_backend
@echo 'Installing frontend dependencies'
make install_frontend

coverage:

coverage: ## run the tests and generate a coverage report
poetry run pytest --cov \
--cov-config=.coveragerc \
--cov-report xml \
--cov-report term-missing:skip-covered \
--cov-report lcov:coverage/lcov-pytest.info


# allow passing arguments to pytest
tests:
tests: ## run the tests
poetry run pytest tests --instafail -ra -n auto -m "not api_key_required" $(args)


format:
format: ## run code formatters
poetry run ruff check . --fix
poetry run ruff format .
cd src/frontend && npm run format

lint:

lint: ## run linters
poetry run mypy --namespace-packages -p "langflow"

install_frontend:

install_frontend: ## install the frontend dependencies
cd src/frontend && npm install


install_frontendci:
cd src/frontend && npm ci


install_frontendc:
cd src/frontend && rm -rf node_modules package-lock.json && npm install


run_frontend:
@-kill -9 `lsof -t -i:3000`
cd src/frontend && npm start


tests_frontend:
ifeq ($(UI), true)
cd src/frontend && npx playwright test --ui --project=chromium
else
cd src/frontend && npx playwright test --project=chromium
endif


run_cli:
@echo 'Running the CLI'
@make install_frontend > /dev/null
Expand All @@ -93,6 +107,7 @@ else
@make start host=$(host) port=$(port) log_level=$(log_level)
endif


run_cli_debug:
@echo 'Running the CLI in debug mode'
@make install_frontend > /dev/null
Expand All @@ -106,6 +121,7 @@ else
@make start host=$(host) port=$(port) log_level=debug
endif


start:
@echo 'Running the CLI'

Expand All @@ -116,30 +132,34 @@ else
endif



setup_devcontainer:
make init
make build_frontend
poetry run langflow --path src/frontend/build


setup_env:
@sh ./scripts/setup/update_poetry.sh 1.8.2
@sh ./scripts/setup/setup_env.sh

frontend:

frontend: ## run the frontend in development mode
make install_frontend
make run_frontend


frontendc:
make install_frontendc
make run_frontend


install_backend:
@echo 'Installing backend dependencies'
@poetry install
@poetry run pre-commit install

backend:

backend: ## run the backend in development mode
@echo 'Setting up the environment'
@make setup_env
make install_backend
Expand All @@ -152,6 +172,7 @@ else
poetry run uvicorn --factory langflow.main:create_app --host 0.0.0.0 --port 7860 --reload --env-file .env --loop asyncio --workers $(workers)
endif


build_and_run:
@echo 'Removing dist folder'
@make setup_env
Expand All @@ -161,18 +182,21 @@ build_and_run:
poetry run pip install dist/*.tar.gz
poetry run langflow run


build_and_install:
@echo 'Removing dist folder'
rm -rf dist
rm -rf src/backend/base/dist
make build && poetry run pip install dist/*.whl && pip install src/backend/base/dist/*.whl --force-reinstall

build_frontend:

build_frontend: ## build the frontend static files
cd src/frontend && CI='' npm run build
rm -rf src/backend/base/langflow/frontend
cp -r src/frontend/build src/backend/base/langflow/frontend

build:

build: ## build the frontend static files and package the project
@echo 'Building the project'
@make setup_env
ifdef base
Expand All @@ -185,13 +209,16 @@ ifdef main
make build_langflow
endif


build_langflow_base:
cd src/backend/base && poetry build
rm -rf src/backend/base/langflow/frontend


build_langflow_backup:
poetry lock && poetry build


build_langflow:
cd ./scripts && poetry run python update_dependencies.py
poetry lock
Expand All @@ -201,7 +228,8 @@ ifdef restore
mv poetry.lock.bak poetry.lock
endif

dev:

dev: ## run the project in development mode with docker compose
make install_frontend
ifeq ($(build),1)
@echo 'Running docker compose up with build'
Expand All @@ -211,25 +239,30 @@ else
docker compose $(if $(debug),-f docker-compose.debug.yml) up
endif


lock_base:
cd src/backend/base && poetry lock

lock_langflow:
poetry lock


lock:
# Run both in parallel
@echo 'Locking dependencies'
cd src/backend/base && poetry lock
poetry lock


publish_base:
cd src/backend/base && poetry publish


publish_langflow:
poetry publish

publish:

publish: ## build the frontend static files and package the project and publish it to PyPI
@echo 'Publishing the project'
ifdef base
make publish_base
Expand All @@ -239,17 +272,11 @@ ifdef main
make publish_langflow
endif

help:

help: ## show this help message
@echo '----'
@echo 'format - run code formatters'
@echo 'lint - run linters'
@echo 'install_frontend - install the frontend dependencies'
@echo 'build_frontend - build the frontend static files'
@echo 'run_frontend - run the frontend in development mode'
@echo 'run_backend - run the backend in development mode'
@echo 'build - build the frontend static files and package the project'
@echo 'publish - build the frontend static files and package the project and publish it to PyPI'
@echo 'dev - run the project in development mode with docker compose'
@echo 'tests - run the tests'
@echo 'coverage - run the tests and generate a coverage report'
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | \
sed -e 's/:.*##\s*/:/' \
-e 's/^\(.\+\):\(.*\)/\\x1b[36mmake \1\\x1b[m:\2/' | \
column -c2 -t -s :']]')"
@echo '----'
1 change: 0 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5ce1192

Please sign in to comment.