Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
python -m pip install --upgrade pip
pip install -e .
pip install -r requirements.txt
pip install -r requirements-dev.txt

- name: Run tests
run: |
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ WORKDIR /app
## Dev Dependencies Layer ######################################################
FROM base as dev_dependencies

COPY requirements.txt /app/requirements.txt
COPY requirements.txt requirements-dev.txt /app/

# speed up pip installs by caching a directory across builds
# https://pythonspeed.com/articles/docker-cache-pip-downloads/
RUN --mount=type=cache,target=/root/.cache \
true \
&& pip install -r /app/requirements.txt \
&& pip install -r /app/requirements-dev.txt \
&& true

# Install kustomize
Expand Down
88 changes: 88 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
SHELL := /usr/bin/env bash
VENV := .venv

##@ General

# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk command is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php

.PHONY: help
help: ## Print help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

.PHONY: install
install: ## Install core requirements
@echo "Installing core requirements..."
pip install -r requirements.txt

.PHONY: venv
venv: ## Create a Python virtual environment with core requirements
@echo "Creating virtual environment..."
@if [ ! -d $(VENV) ]; then \
python3 -m venv $(VENV); \
source $(VENV)/bin/activate; \
pip install --upgrade pip; \
else \
echo "Virtual environment already exists, no action needed."; \
exit 1; \
fi
@echo "Installing core dependencies..."
@source $(VENV)/bin/activate; pip install -r requirements.txt; pip install -e .;
@printf "\nRun \033[35msource $(VENV)/bin/activate\033[0m to activate the virtual environment\n"

##@ Development

.PHONY: format
format: ## Autoformat code
@echo "Formatting Python code..."
ruff format ./fmperf
ruff format ./examples
@echo "Sorting requirements..."
@for req in $$(ls requirements*.txt); do sort -f $$req -o $$req; done

.PHONY: lint
lint: ## Perform linting
black --check ./fmperf
black --check ./examples

.PHONY: type-check
type-check: ## Perform type checking
@echo "Running type checking with mypy..."
mypy --strict ./fmperf
mypy --strict ./examples

.PHONY: test
test: ## Run tests
pytest fmperf/tests/

.PHONY: install-dev
install-dev: ## Install development requirements
@echo "Installing development requirements..."
pip install -r requirements-dev.txt

.PHONY: install-all
install-all: install install-dev ## Install core and development requirements

.PHONY: venv-dev
venv-dev: venv ## Create a Python virtual environment with core and dev requirements
@echo "Installing dev dependencies..."
@source $(VENV)/bin/activate; pip install -r requirements-dev.txt
@printf "\nRun \033[35msource $(VENV)/bin/activate\033[0m to activate the virtual environment\n"

.PHONY: clean
clean: ## Remove cache, backup, and temporary files
@echo "Running cleanup"
find fmperf/ -depth -name '__pycache__' -exec rm -vrf {} \;
rm -vrf fmperf.egg-info
find -depth -name '.pytest_cache' -exec rm -vrf {} \;
find -depth -name '.ipynb_checkpoints' -exec rm -vrf {} \;
ruff clean
rm -rf .mypy_cache
5 changes: 5 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
black~=24.0
mypy>=1.14.1
pytest
Comment thread
wangchen615 marked this conversation as resolved.
ruff>=0.9.4
wheel
7 changes: 2 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
durations
kubernetes==24.2.0
black~=24.0
pandas
pyyaml
pytest
wheel
scikit-learn
durations
transformers
sentencepiece
transformers