Skip to content

Commit

Permalink
big reorganization
Browse files Browse the repository at this point in the history
- remove unused stuff
- port existing noxfile.py with general tasks
- pin dependencies with pip-deepfreeze
- switch to pyproject.toml and hatch as build tool
- use hatch for version bumping
- most tests removed in order to get a clean slate:
  - the work mapper ones were self contained so I kept them
  • Loading branch information
salotz committed Apr 7, 2023
1 parent fe00702 commit eb9e7aa
Show file tree
Hide file tree
Showing 65 changed files with 782 additions and 3,688 deletions.
19 changes: 19 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[run]
branch = True
parallel = True
omit =
tests/*

source = src/

[report]
exclude_lines =
@overload
pragma: no cover
raise NotImplementedError
if TYPE_CHECKING:
pass
if __name__ == "__main__":

# SNIPPET: use this to fail CI for missing test coverage
# fail_under = 100
49 changes: 49 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Contributing

Developing on wepy

After you have cloned the repo you should have a copy of Python 3.10 installed
and accessible to path as `python3.10`.

Then you should be able to start coding and running tests:

```sh
make test-unit
```

To build the package:

```sh
make build
```

To see all the commands run `make` or:

```sh
make help
```

All the virtual environment creation and installation is taken care behind the
scenes.

If you want a standalone environment you can activate in your shell run:

```sh
make env
```

Which creates the `.venv` folder. For convenience it can be activated with:

```sh
. ./env.sh
```


## TODOs

Note that there are stubs for performing checks like linting, formatting etc.
that aren't used in this project, but could be added at a later time.

In order to get tests passing many bad tests were deleted.

Building of documentation is also not implemented at the moment.
127 changes: 127 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
## Notes on this file. The `help` target parses the file and can generate
## headings and docstrings for targets, in the order they are in the file. To
## create a heading make a comment like `##@ Heading Content`. To document
## targets make a comment on the same line as the target name with two `##
## docstring explanation...`. To leave a target undocumented simply provide no
## docstring.

PYTHON=python3.11
TMPDIR=.tmp

##@ Getting Started

env: ## Rebuild the main development environment
nox -s dev_external
echo "Run this to activate dev env: . env.sh"
.PHONY: env

##@ Housekeeping

clean-all: clean clean-docs clean-env clean-compose clean-hooks ## run all clean commands
.PHONY: clean-all

clean: ## Clean temporary files, directories etc.
rm -rf $(TMPDIR)
rm -rf dist .pytest_cache .mypy_cache .coverage .venv .nox .hatch htmlcov
find . -type f -name "*.pyc" -print -delete
hatch clean
.PHONY: clean

clean-env: ## Clean the dev environments
rm -rf .venv
.PHONY: clean-env

##@ QA (TODO)

# format: ## Run source code formatters manually.
# nox -s format
# .PHONY: docstrings

# validate: ## Run all linters, type checks, static analysis, etc.
# nox -s validate
# .PHONY: validate

# format-check: ## Run code formatting checks
# nox -s format_check
# .PHONY: format-check

# # check: ## Run only miscellaneous maintenance checks
# # .PHONY: check

# lint: ## Run only the linters (non-autoformatters).
# nox -s lint
# .PHONY: lint

# docstring-check: ## Run docstring coverage only.
# nox -s docstring_lint
# .PHONY: docstring

# typecheck: ## Run only the type checker (requires mypy)
# nox -s typecheck
# .PHONY: typecheck

##@ Dev

test-unit: ## Run unit tests with coverage report
nox -s tests_unit
.PHONY: test

coverage: ## Report on missing coverage. (Run 'test-unit' to generate new stats)
nox -s coverage
.PHONY: coverage

serve-coverage: ## Run a temporary web server to display detailed coverage report
python3 -m http.server --directory htmlcov 4322
.PHONY: serve-coverage


##@ Documentation (TODO)

# docs: ## TODO: Build the documentation
# nox -s docs
# .PHONY: docs

# clean-docs: ## TODO: Clean temporary files for documentation
# rm -rf docs/_api docs/_build
# .PHONY: clean-docs

# serve-docs: ## TODO: Run a temporary web server to display current documentation build
# python3 -m http.server --directory docs/_build 4323
# .PHONY: serve-docs


##@ Release Management

pin: pyproject.toml ## Pin the project dependency versions
nox -s pin
.PHONY: pin

bumpversion: ## Bump the minor version for the project
nox -s bumpversion
.PHONY: bumpversion

build: ## Run the python build/packaging, generate sdist & wheel
nox -s build
.PHONY: build

publish: ## Publish the package to indices
nox -s publish
.PHONY: publish

##@ Help

# An automatic help command: https://www.padok.fr/en/blog/beautiful-makefile-awk
.DEFAULT_GOAL := help

help: ## (DEFAULT) This command, show the help message
@echo "See CONTRIBUTING.md for dependencies, then run this:"
@echo ""
@echo "If you want a shell in a virtual environment with everything:"
@echo " > make env"
@echo " > . ./env.sh"
@echo ""
@echo "Do testing:"
@echo " > make test-unit"
@echo ""
@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: help
6 changes: 6 additions & 0 deletions dev/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This contains external specifications of the different profiles of dependencies
needed for different tasks.

They are split up this way to allow for the absolute minimum dependencies needed
in environments like CI where we want performance to be optimal and reducing the
number of dependencies can help that a lot.
7 changes: 7 additions & 0 deletions dev/docs.requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sphinx
sphinxcontrib-napoleon
sphinxcontrib-newsfeed
sphinxcontrib-bibtex
sphinxcontrib-newsfeed
nbsphinx
notebook
2 changes: 2 additions & 0 deletions dev/interactive.requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ipython
pdbpp
5 changes: 5 additions & 0 deletions dev/qa.requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
black
isort
flake8
flake8-bugbear
interrogate
3 changes: 3 additions & 0 deletions dev/testing.requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest
coverage
pytest-cov
1 change: 1 addition & 0 deletions dev/typechecking.requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mypy
1 change: 1 addition & 0 deletions env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
. ./.venv/bin/activate
3 changes: 0 additions & 3 deletions envs/dev/dev.requirements.list

This file was deleted.

7 changes: 0 additions & 7 deletions envs/dev/env.yaml

This file was deleted.

1 change: 0 additions & 1 deletion envs/dev/pyversion.txt

This file was deleted.

44 changes: 0 additions & 44 deletions envs/dev/requirements.in

This file was deleted.

Loading

0 comments on commit eb9e7aa

Please sign in to comment.