From e3ccf50e21795bb4c81ea353b7dec7ba0598139d Mon Sep 17 00:00:00 2001 From: Nick Masluk Date: Fri, 23 May 2025 18:40:00 -0400 Subject: [PATCH 1/6] Separate core and development requirements --- .github/workflows/unittests.yml | 1 + requirements-dev.txt | 5 +++++ requirements.txt | 7 ++----- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 requirements-dev.txt diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index d897137..ea1309f 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -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: | diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..70cfafd --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,5 @@ +black~=24.0 +mypy>=1.14.1 +pytest +ruff>=0.9.4 +wheel diff --git a/requirements.txt b/requirements.txt index c1f7226..afed737 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,7 @@ +durations kubernetes==24.2.0 -black~=24.0 pandas pyyaml -pytest -wheel scikit-learn -durations -transformers sentencepiece +transformers From 926d2713eb1c638e40044c87aa310783b56dda90 Mon Sep 17 00:00:00 2001 From: Nick Masluk Date: Fri, 23 May 2025 18:40:11 -0400 Subject: [PATCH 2/6] Add Makefile --- Makefile | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5452836 --- /dev/null +++ b/Makefile @@ -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 commands 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\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, leaving as-is"; \ + 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 From 1025cc7cd2477f56f2e6868fe353e8975d2c87c1 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Wed, 4 Jun 2025 14:12:18 -0400 Subject: [PATCH 3/6] Update Makefile Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5452836..ac78bea 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ VENV := .venv # 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 commands is responsible for reading 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. From 8f4f0dc3dde7848f549173cdd5c4801c6b24dee4 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Wed, 4 Jun 2025 14:12:30 -0400 Subject: [PATCH 4/6] Update Makefile Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ac78bea..640e8fa 100644 --- a/Makefile +++ b/Makefile @@ -31,8 +31,8 @@ venv: ## Create a Python virtual environment with core requirements source $(VENV)/bin/activate; \ pip install --upgrade pip; \ else \ - echo "Virtual environment already exists, leaving as-is"; \ - exit 1; \ + echo "Virtual environment already exists, no action needed."; \ + exit 0; \ fi @echo "Installing core dependencies..." @source $(VENV)/bin/activate; pip install -r requirements.txt; pip install -e .; From a00a27235eac3ff82ded363ab1895272523aef0b Mon Sep 17 00:00:00 2001 From: Nick Masluk Date: Wed, 4 Jun 2025 14:33:47 -0400 Subject: [PATCH 5/6] Ensure recipe ends if virtual environment already exists --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 640e8fa..c799e9e 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ venv: ## Create a Python virtual environment with core requirements pip install --upgrade pip; \ else \ echo "Virtual environment already exists, no action needed."; \ - exit 0; \ + exit 1; \ fi @echo "Installing core dependencies..." @source $(VENV)/bin/activate; pip install -r requirements.txt; pip install -e .; From 404c0fdcd421de1e7cf78b74ab7effbf52dff141 Mon Sep 17 00:00:00 2001 From: Nick Masluk Date: Mon, 9 Jun 2025 20:51:37 -0400 Subject: [PATCH 6/6] Add development requirements to Dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e429721..ce3d785 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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