Mini-Transformer / Makefile
AlaBoussoffara's picture
fixed weight download
e64ea16
Raw
History Blame Contribute Delete
3.48 kB
ENV?=mini-transformer
CONDA_RUN=conda run -n $(ENV)
PYTHON?=python
.PHONY: help create-env install precommit lint lint-check fmt fmt-check type test cov fetch-test fetch-small infer serve ui clean clean-all docker-build-dev docker-run-dev docker-build-infer docker-run-infer
help:
@echo "Available targets:"
@echo " create-env - Create or update the $(ENV) conda environment"
@echo " install - Install project with dev/notebook/viz extras into the active environment"
@echo " precommit - Run all pre-commit hooks"
@echo " lint - Run ruff lint (auto-fixes with fmt beforehand)"
@echo " lint-check - Run ruff in check-only mode"
@echo " fmt - Format code with ruff + black"
@echo " fmt-check - Check formatting without modifying files"
@echo " type - Run mypy type checks"
@echo " test - Run unit tests"
@echo " cov - Run unit tests with coverage report"
@echo " fetch-test - Download the AlaBoussoffara/transformer_test model"
@echo " fetch-small - Download the AlaBoussoffara/transformer_small model"
@echo " infer - Quick inference using the demo model"
@echo " serve - Start the FastAPI server (reload mode)"
@echo " ui - Launch the Chainlit UI"
@echo " clean - Remove build/test caches"
@echo " clean-all - Clean caches plus notebooks outputs"
@echo " docker-build-dev - Build the development Docker image"
@echo " docker-run-dev - Drop into the development container"
@echo " docker-build-infer - Build the inference Docker image"
@echo " docker-run-infer - Run the inference container exposing the Chainlit UI"
create-env:
conda env create -n $(ENV) -f environment.yml || conda env update -n $(ENV) -f environment.yml
$(CONDA_RUN) pip install -e .[dev,notebook,viz]
$(CONDA_RUN) pre-commit install
install:
$(PYTHON) -m pip install -e .[dev,notebook,viz]
precommit:
$(CONDA_RUN) pre-commit run --all-files
lint: fmt
$(CONDA_RUN) ruff check .
lint-check:
$(CONDA_RUN) ruff check .
fmt:
$(CONDA_RUN) ruff format .
$(CONDA_RUN) black src tests
fmt-check:
$(CONDA_RUN) ruff format . --check
$(CONDA_RUN) black src tests --check
type:
$(CONDA_RUN) mypy src
test:
$(CONDA_RUN) pytest
cov:
$(CONDA_RUN) pytest --cov=mini_transformer --cov-report=term-missing
fetch-test:
mini-transformer-fetch AlaBoussoffara/transformer_test --force
cp -rf ./trained_models/AlaBoussoffara__transformer_test/test_model_v1 ./trained_models/test_model_v1
rm -rf ./trained_models/AlaBoussoffara__transformer_test
fetch-small:
mini-transformer-fetch AlaBoussoffara/transformer_small --force
cp -rf ./trained_models/AlaBoussoffara__transformer_small/small_model_v1 ./trained_models/small_model_v1
rm -rf ./trained_models/AlaBoussoffara__transformer_small/
infer:
$(CONDA_RUN) mini-transformer-infer --model small_model_v1 -t "translate this sentence."
serve:
$(CONDA_RUN) mini-transformer-serve --model small_model_v1 --reload
ui:
$(CONDA_RUN) mini-transformer-ui --model small_model_v1 --host 0.0.0.0 --port 8000
clean:
rm -rf .pytest_cache .mypy_cache .ruff_cache dist build *.egg-info
clean-all: clean
rm -rf notebooks/.ipynb_checkpoints outputs/*
docker-build-dev:
docker compose build dev --no-cache
docker-run-dev:
docker compose run --rm dev bash
docker-build-infer:
docker compose build infer --no-cache
docker-run-infer:
docker compose run --rm --service-ports infer