Init project

master
Drew Bednar 1 year ago
commit 999d0e0bfb

@ -0,0 +1,6 @@
[run]
source = speech_collect
omit = test*
[report]
show_missing = True

@ -0,0 +1,23 @@
kind: pipeline
type: docker
name: CI Test Pipeline
steps:
- name: greeting
image: alpine
commands:
- echo "Welcome to drone\n"
- name: Unit Tests
image: python:3.11-bullseye
commands:
- bash -c './scripts/run_unit_tests.sh'
trigger:
event:
- pull_request
- push
# Secrets used to pull private images
image_pull_secrets:
- dockerconfigjson

62
.gitignore vendored

@ -0,0 +1,62 @@
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Pycharm
.idea

@ -0,0 +1,39 @@
default_stages: [commit, push]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: debug-statements
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.5
hooks:
- id: shellcheck
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
args: ["speech_collect", "./tests/"]
types: [ python ]
- repo: local
hooks:
- id: isort
name: isort
entry: isort
language: system
types: [python]
require_serial: true
- id: ruff
name: ruff
entry: ruff
language: system
types: [python]
args: [
# '-rn', # Only display messages
# '-sn', # Don't display the score
# '--disable=C,R,W0511', # Disable C and R type messages, and TODO fixme warning
]
require_serial: true

@ -0,0 +1,10 @@
MIT License
Copyright (c) 2023, Drew Bednar
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,26 @@
# speech_collect
A speech collection tool for machine learning datasets
## First time setup
Create a virtual environment and activate it. Now from the root project directory run `./scripts/bootstrap`. This will install `pip-tools` and sync any dependencies for the first time.
## Dependency management
Dependencies are managed via [pip-tools].
### Adding a dependency
To add a dependency, edit `requirements.in` (or `dev-requirements.in`
for dev dependencies) and add your dependency then run `pip-compile
requirements.in`.
### Syncing dependencies
Run `pip-sync requirements.txt dev_requirements.txt`.
## Testing
Run the tests by invoking `py.test` in the project root. Make sure you
run any pending migrations beforehand.

@ -0,0 +1,9 @@
black
invoke
isort
pip-tools
pre-commit
pytest
pytest-cov
shellcheck-py==0.9.0.5
ruff

@ -0,0 +1,87 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile dev-requirements.in
#
black==23.11.0
# via -r dev-requirements.in
build==1.0.3
# via pip-tools
cfgv==3.4.0
# via pre-commit
click==8.1.7
# via
# black
# pip-tools
coverage[toml]==7.3.2
# via
# coverage
# pytest-cov
distlib==0.3.7
# via virtualenv
exceptiongroup==1.2.0
# via pytest
filelock==3.13.1
# via virtualenv
identify==2.5.32
# via pre-commit
iniconfig==2.0.0
# via pytest
invoke==2.2.0
# via -r dev-requirements.in
isort==5.12.0
# via -r dev-requirements.in
mypy-extensions==1.0.0
# via black
nodeenv==1.8.0
# via pre-commit
packaging==23.2
# via
# black
# build
# pytest
pathspec==0.11.2
# via black
pip-tools==7.3.0
# via -r dev-requirements.in
platformdirs==4.0.0
# via
# black
# virtualenv
pluggy==1.3.0
# via pytest
pre-commit==3.5.0
# via -r dev-requirements.in
pyproject-hooks==1.0.0
# via build
pytest==7.4.3
# via
# -r dev-requirements.in
# pytest-cov
pytest-cov==4.1.0
# via -r dev-requirements.in
pyyaml==6.0.1
# via pre-commit
ruff==0.1.6
# via -r dev-requirements.in
shellcheck-py==0.9.0.5
# via -r dev-requirements.in
tomli==2.0.1
# via
# black
# build
# coverage
# pip-tools
# pyproject-hooks
# pytest
typing-extensions==4.8.0
# via black
virtualenv==20.24.7
# via pre-commit
wheel==0.42.0
# via pip-tools
# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools

@ -0,0 +1,37 @@
[tool.isort]
profile = "black"
line_length = 120
force_single_line = true
filter_files = true
[tool.black]
line-length = 120
skip-string-normalization = true
exclude = "(^/\\.git|^/env/|^/venv/|^/node_modules/)"
[tool.ruff]
line-length = 120
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]

@ -0,0 +1 @@
litestar[standard]

@ -0,0 +1,100 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile requirements.in
#
anyio==4.1.0
# via
# httpx
# litestar
# watchfiles
certifi==2023.11.17
# via
# httpcore
# httpx
click==8.1.7
# via
# litestar
# rich-click
# uvicorn
editorconfig==0.12.3
# via jsbeautifier
exceptiongroup==1.2.0
# via anyio
faker==20.1.0
# via polyfactory
fast-query-parsers==1.0.3
# via litestar
h11==0.14.0
# via
# httpcore
# uvicorn
httpcore==1.0.2
# via httpx
httptools==0.6.1
# via uvicorn
httpx==0.25.2
# via litestar
idna==3.6
# via
# anyio
# httpx
jinja2==3.1.2
# via litestar
jsbeautifier==1.14.11
# via litestar
litestar[standard]==2.4.1
# via -r requirements.in
markdown-it-py==3.0.0
# via rich
markupsafe==2.1.3
# via jinja2
mdurl==0.1.2
# via markdown-it-py
msgspec==0.18.4
# via litestar
multidict==6.0.4
# via litestar
polyfactory==2.12.0
# via litestar
pygments==2.17.2
# via rich
python-dateutil==2.8.2
# via faker
python-dotenv==1.0.0
# via uvicorn
pyyaml==6.0.1
# via
# litestar
# uvicorn
rich==13.7.0
# via
# litestar
# rich-click
rich-click==1.7.1
# via litestar
six==1.16.0
# via
# jsbeautifier
# python-dateutil
sniffio==1.3.0
# via
# anyio
# httpx
typing-extensions==4.8.0
# via
# litestar
# polyfactory
# rich-click
# uvicorn
uvicorn[standard]==0.24.0.post1
# via litestar
uvloop==0.19.0
# via
# litestar
# uvicorn
watchfiles==0.21.0
# via uvicorn
websockets==12.0
# via uvicorn

@ -0,0 +1,10 @@
#!/usr/bin/env bash
function _setup_env() {
# build a virtual env
if [ -z "${VIRTUAL_ENV}" ]; then
python3 -m venv env
# shellcheck source=/dev/null
source env/bin/activate
fi
}

@ -0,0 +1,38 @@
#!/usr/bin/env bash
# setting -e to exit immediately on a command failure.
# set -o pipefail sets the exit code of a pipeline to
# that of the rightmost command to exit with a non-zero status,
# or to zero if all commands of the pipeline exit successfully.
# set -u affects variables. When set, a reference to any variable
# you haven't previously defined - with the exceptions of $* and $@ -
# is an error, and causes the program to immediately exit
set -eo pipefail
IFS=$'\n\t'
# shellcheck source=/dev/null
source "$(dirname "$0")/_common.sh"
function project_bootstrap() {
_setup_env
pip install -U pip pip-tools=='7.3.0'
pip-compile requirements.in
pip-compile dev-requirements.in
pip-sync requirements.txt dev-requirements.txt
}
function install_precommit_hooks() {
if [ ! -d ".git" ]; then
git init
fi
if [ -z "$VIRTUAL_ENV" ]; then
echo "warning: you are not in a virtualenv"
exit 1
fi
pre-commit install
}
project_bootstrap
install_precommit_hooks

@ -0,0 +1,12 @@
#! /usr/bin/env bash
set -ex
# shellcheck source=/dev/null
source "$(dirname "$0")/_common.sh"
if [ "${DRONE}" == "true" ]; then
_setup_env
pip install -r requirements.txt -r dev-requirements.txt
fi
exec "${VIRTUAL_ENV}/bin/python" -m pytest -vv --cov "$@"

@ -0,0 +1,5 @@
class Example:
"""An example class"""
def __init__(self, name):
self.name = name

@ -0,0 +1,6 @@
from speech_collect.example import Example
def test_example():
my_example = Example(name="dirp")
assert my_example.name == "dirp"
Loading…
Cancel
Save