Skip to content

Commit

Permalink
Bootstrap with ds-template
Browse files Browse the repository at this point in the history
  • Loading branch information
rAum committed Nov 2, 2023
1 parent d77fef7 commit d3c4f3b
Show file tree
Hide file tree
Showing 41 changed files with 934 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[bumpversion]
current_version = 0.0.1-dev
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?
serialize =
{major}.{minor}.{patch}-{release}
{major}.{minor}.{patch}

[bumpversion:part:release]
optional_value = prod
first_value = dev
values =
dev
prod

[bumpversion:file:./src/ds_pycontain/VERSION]
15 changes: 15 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[run]
branch = True
source =
src

omit =
*__init__*
*__version__*
*/thirdparty/**

[report]
exclude_lines =
pragma: no cover
if __name__ == .__main__.
show_missing = True
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/venv/
docs/
tests/
ci/
.vscode/
.idea/
.pytest_cache/
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This is a standard to preconfigure editors
# check: https://editorconfig.org/
root = true

# 4 space indentation
[*.py]
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = false
end_of_line = lf
12 changes: 12 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[flake8]
ignore=
# line too long - is to be checked by black
E501,
# E203 (spaces around :)
E203,
# and W503 (line break before binary operator) are output as a result of Black formatting
W503

dictionaries=en_US,python,technical
docstring-convention=google
spellcheck-targets=comments
84 changes: 84 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Directories
.vscode/
.idea/
.neptune/
.pytest_cache/
.mypy_cache/
venv/
__pycache__/
**.egg-info/

# 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

# Sphinx documentation
docs/_build/
public/
# autogenerated package license table
docs/licenses_table.rst

# license dump file
licenses.txt

# File formats
*.onnx
*.pyc
*.pt
*.pth
*.pkl
*.mar
*.torchscript
**/.ipynb_checkpoints
**/dist/
**/checkpoints/
**/outputs/

# Other env files
.python-version
pyvenv.cfg
pip-selfcheck.json


# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# dotenv
.env

# coverage and pytest reports
coverage.xml
report.xml

# CMake
cmake-build-*/
1 change: 1 addition & 0 deletions .libraries-whitelist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkg_resources
24 changes: 24 additions & 0 deletions .license-whitelist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
3-Clause BSD License
Apache 2
Apache License 2
Apache Software License
Apache Software License, BSD License
Apache Software License, MIT License
Apache-2
Apache License, Version 2
BSD
BSD License
BSD License, Apache Software License
CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
Freely Distributable
ISC License (ISCL)
MIT
MIT License
MIT License, Mozilla Public License 2.0 (MPL 2.0)
Mozilla Public License 2.0 (MPL 2.0)
Public Domain
Python Software Foundation License
Python Software Foundation License, MIT License
Unlicense
Proprietary License
Historical Permission Notice and Disclaimer (HPND)
91 changes: 91 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: trailing-whitespace
exclude: ".bumpversion.cfg"
- id: check-ast
- id: check-added-large-files
- id: check-toml
- id: check-json
- id: check-yaml

# PEP 8 compliant opinionated formatter.
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
exclude: (docs/)
- id: black-jupyter
exclude: (docs/)

# Cleaning unused imports.
- repo: https://github.com/hadialqattan/pycln
rev: v2.2.2
hooks:
- id: pycln
args: ["-a"]
exclude: (docs/)

# Modernizes python code and upgrade syntax for newer versions of the language
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py38-plus]

# Used to have proper type annotations for library code.
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
args: []
# You can add additional plugins for mypy below
# such as types-python-dateutil
additional_dependencies: []
exclude: (/test_|setup.py|/tests/|docs/)

# Sort imports alphabetically, and automatically separated into sections and by type.
- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
exclude: (docs/)

# Checks Python source files for errors.
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
name: flake8
entry: flake8
language: python
types: [python]
args: [--config, .flake8]
exclude: (docs/)

# Enforces a coding standard, looks for code smells, and can make suggestions about how the code could be refactored.
- repo: https://github.com/pycqa/pylint
rev: v3.0.1
hooks:
- id: pylint
exclude: (/test_|tests/|docs/)
# # You can add additional plugins for pylint here,
# here is an example for pydantic, remember to enable it in pyproject.toml
# additional_dependencies:
# - 'pylint_pydantic'
# args:
# # pylint can have issue with python libraries based on C
# # if it fails to find some objects likely you need to add them
# # here:
# ["--extension-pkg-whitelist=pydantic"]

# Finds common security issues in Python code.
- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
rev: v1.0.6
hooks:
- id: python-bandit-vulnerability-check
args: [-c, pyproject.toml, --recursive, src, -ll]
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
recursive-include src/ py.typed *.pyi VERSION
global-exclude __pycache__
global-exclude *.py[cod]
88 changes: 88 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# deepsense.ai pycontain


It is a simple wrapper library around docker python API to make it easier to use in, in particular for langchain.

Project created with ds-template: [https://deepsense-ai.github.io/ds-template/](https://deepsense-ai.github.io/ds-template/).


# Setup developer environment

To start, you need to setup your local machine.

## Setup venv

You need to setup virtual environment, simplest way is to run from project root directory:

```bash
$ ./setup_dev_env.sh
$ source venv/bin/activate
```
This will create a new venv and run `pip install -r requirements-dev.txt`.

## Install pre-commit

To ensure code quality we use pre-commit hook with several checks. Setup it by:

```
pre-commit install
```

All updated files will be reformatted and linted before the commit.

To reformat and lint all files in the project, use:

`pre-commit run --all-files`

The used linters are configured in `.pre-commit-config.yaml`. You can use `pre-commit autoupdate` to bump tools to the latest versions.

## Autoreload within notebooks

When you install project's package add below code (before imports) in your notebook:
```
# Load the "autoreload" extension
%load_ext autoreload
# Change mode to always reload modules: you change code in src, it gets loaded
%autoreload 2
```
Read more about different modes in [documentation](https://ipython.org/ipython-doc/3/config/extensions/autoreload.html).

All code should be in `src/` to make reusability and review straightforward, keep notebooks simple for exploratory data analysis.
See also [Cookiecutter Data Science opinion](https://drivendata.github.io/cookiecutter-data-science/#notebooks-are-for-exploration-and-communication).

# Project documentation

In `docs/` directory are Sphinx RST/Markdown files.

To build documentation locally, in your configured environment, you can use `build_docs.sh` script:

```bash
$ ./build_docs.sh
```

Then open `public/index.html` file.

Please read the official [Sphinx documentation](https://www.sphinx-doc.org/en/master/) for more details.



# Semantic version bump

To bump version of the library please use `bump2version` which will update all version strings.

NOTE: Configuration is in `.bumpversion.cfg` and **this is a main file defining version which should be updated only with bump2version**.

For convenience there is bash script which will create commit, to use it call:

```bash
# to create a new commit by increasing one semvar:
$ ./bump_version.sh minor
$ ./bump_version.sh major
$ ./bump_version.sh patch
# to see what is going to change run:
$ ./bump_version.sh --dry-run major
```
Script updates **VERSION** file and setup.cfg automatically uses that version.

You can configure it to update version string in other files as well - please check out the bump2version configuration file.

16 changes: 16 additions & 0 deletions build_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Force Sphinx to rebuild documentation - otherwise it generates incosistencies.
rm -rf public/ docs/_build

# Exit on error for the next commands
set -e -x

# Activate venv for licenses and also it simplifies sphinx code documentation generation.
. venv/bin/activate

# Generate a table with all installed libraries, licenses etc
pip-licenses --from=mixed --format rst --with-urls --with-description --output-file=docs/licenses_table.rst

# Build sphinx docs to public/ directory
sphinx-build -d docs/_build/doctrees docs/ public/
3 changes: 3 additions & 0 deletions bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -e
bump2version --verbose --commit $@
Loading

0 comments on commit d3c4f3b

Please sign in to comment.