Skip to content

Commit

Permalink
Merge pull request #2 from project-delphi/1-fix-makefile-venv-issue
Browse files Browse the repository at this point in the history
fix(makefile): update with venv activation fix
  • Loading branch information
project-delphi authored Oct 20, 2023
2 parents 8caadc0 + b067815 commit ecb0e29
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 22 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ repos:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.10.0
hooks:
- id: black
- repo: https://github.com/commitizen-tools/commitizen
rev: 3.10.0
rev: 3.12.0
hooks:
- id: commitizen
stages: [commit-msg]
Expand All @@ -43,7 +43,7 @@ repos:
hooks:
- id: validate-pyproject
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.0
rev: v1.6.1
hooks:
- id: mypy
args: ["--config-file", "pyproject.toml"]
Expand All @@ -53,7 +53,7 @@ repos:
- types-chardet
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.292
rev: v0.1.1
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
Expand Down
59 changes: 43 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SHELL := /bin/bash
.ONESHELL:

.DEFAULT_GOAL:=help

Expand All @@ -16,56 +17,58 @@ list:
env-create:# Create virtual environment called .venv
python3 -m venv .venv

.PHONY: env-activate
env-activate:# Activate virtual environment
source ./.venv/bin/activate
.PHONY: env-ishell-activate
env-activate:# Activate virtual environment for interactive shells
echo 'source ./.venv/bin/activate' >> ~/.bashrc


.PHONY: env-deactivate
env-deactivate:# Deactivate virtual environment
env-deactivate:# Deactivate virtual environment, doesn't work unless virtual environment is activated
source deactivate

.PHONY: env-delete
env-delete:# Delete environment directory .venv
rm -rf .venv

.PHONY: env-initiate
env-initiate: env-create env-activate# Create and activate virtual environment at .venv
env-initiate: env-create env-ishell-activate# Create and activate virtual environment at .venv for interactive shells

# 3rd party package dependencies

.PHONY: install-upgrade-pip
install-upgrade-pip:# Upgrade pip version
source ./.venv/bin/activate
pip install --upgrade pip

.PHONY: install-dev
install-dev:# Install developer dependencies (formatting, linting)
pip install -r requirements/requirements_dev.txt
source ./.venv/bin/activate
pip install -r requirements_dev.txt


.PHONY: install-test
install-test:# Install dependencies for testing
pip install -r requirements/requirements_test.txt

.PHONY: install-run
install-run:# Install application only dependencies
pip install -r requirements/requirements_run.txt
source ./.venv/bin/activate
pip install -r requirements.txt

.PHONY: install
install: install-upgrade-pip install-dev install-test install-run# Upgrade pip and install developer, test & application dependencies
install: install-upgrade-pip install-dev install-run# Upgrade pip and install developer, test & application dependencies

.PHONY: uninstall-dev
uninstall-dev:# Uninstall developer dependencies
pip uninstall -r requirements/requirements_dev.txt
source ./.venv/bin/activate
pip uninstall -r requirements_dev.txt

.PHONY: uninstall-test
uninstall-test:# Uninstall test dependencies
pip uninstall -r requirements/requirements_test.txt

.PHONY: uninstall-run
uninstall-run:# Uninstall application only dependencies
pip uninstall -r requirements/requirements_run.txt
source ./.venv/bin/activate
pip uninstall -r requirements.txt

.PHONY: uninstall
uninstall:# Uninstall all dependencies
source ./.venv/bin/activate
python -m pip uninstall -y -r <(pip freeze)

# Sandboxing: virtual environment & dependencies
Expand All @@ -90,10 +93,12 @@ sandbox: sandbox-destroy sandbox-new## Destroy and make a new sandbox

.PHONY: lint-ruff
lint-ruff:# Lint code using ruff for various styles and fix
source ./.venv/bin/activate
python -m ruff check --fix .

.PHONY: lint-mypy
lint-mypy:# Lint code using mypy type hints
source ./.venv/bin/activate
python -m mypy -p src --check-untyped-defs

.PHONY: lint-typecheck
Expand All @@ -107,6 +112,7 @@ lint: lint-ruff lint-typecheck## Lint code and docstrings

.PHONY: format-black
format-black:# Format code using black
source ./.venv/bin/activate
python -m black .

.PHONY: format
Expand All @@ -116,10 +122,12 @@ format: format-black## Format code

.PHONY: pytest
pytest:# Run tests using pytest
source ./.venv/bin/activate
python -m pytest -vv src

.PHONY: coverage
coverage:# Test coverage analysis
source ./.venv/bin/activate
coverage run -m pytest

.PHONY: tests
Expand All @@ -132,6 +140,7 @@ serve:# Serve app using microservices

.PHONY: app
app:# Run application in app.py
source ./.venv/bin/activate
python -m app.py

.PHONY: run
Expand All @@ -141,6 +150,7 @@ run: app# Run applcation

.PHONY: package-install
package-install:## Install edtiable src package
source ./.venv/bin/activate
python -m pip install -e .

# Cleaning code generated artifacts
Expand Down Expand Up @@ -197,38 +207,47 @@ setup: sandbox clean pre-commit-run tests # remake of environment along with tes

.PHONY: ml-data-download
ml-data-download:# Download data
source ./.venv/bin/activate
python -m src/ml/data_download.py

.PHONY: ml-data-preprocess
ml-data-preprocess:# Preprocess data
source ./.venv/bin/activate
python -m src/ml/data_preprocess.py

.PHONY: ml-data-encode
ml-data-encode:# Encode data
source ./.venv/bin/activate
python -m src/ml/data_encode.py

.PHONY: ml-data-split
ml-data-split:# Split data
source ./.venv/bin/activate
python -m src/ml/data_split.py

.PHONY: ml-dev-train-parameters
ml-dev-train-parameters:# Develop model by training parameters
source ./.venv/bin/activate
python -m src/ml/dev_train_parameters.py

.PHONY: ml-dev-tune-hyperparameters
ml-dev-tune-hyperparameters:# Develop model by tuning hyperparaemters
source ./.venv/bin/activate
python -m src/ml/dev_tune_hyperparameters.py

.PHONY: ml-model-test-performance
ml-model-test-performance:# Unbiased model performance estimate
source ./.venv/bin/activate
python -m src/ml/model_test_performance.py

.PHONY: ml-model-upload
ml-model-upload:# Upload model to cloud
source ./.venv/bin/activate
python -m src/ml/model_upload.py

.PHONY: ml-model-serve-api
ml-model-serve-api:# Serve model using microservices architecture
source ./.venv/bin/activate
python -m src/ml/model_serve_api.py

.PHONY: ml-model-learn
Expand Down Expand Up @@ -260,3 +279,11 @@ deploy:
# GITHUB_REPO_URL: ${{ secrets.GITHUB_REPO_URL }}
# GITHUB_BRANCH: ${{ secrets.GITHUB_BRANCH }}
# GITHUB_CONNECTION_ARN: ${{ secrets.GITHUB_CONNECTION_ARN }}

.PHONY: git-add-precommit
git-add-precommit:
git add . && pre-commit run

.PHONY: random-password
random-password:
openssl rand -hex 10
File renamed without changes.
2 changes: 0 additions & 2 deletions requirements/requirements_test.txt

This file was deleted.

2 changes: 2 additions & 0 deletions requirements/requirements_dev.txt → requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ mypy
nbstripout
pre-commit
pydoclint
pytest
pytest-cov
pyupgrade
ruff
tqdm

0 comments on commit ecb0e29

Please sign in to comment.