Skip to content

Commit

Permalink
Set up python package and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-lightly committed Nov 6, 2023
1 parent 13dafb0 commit d126d11
Show file tree
Hide file tree
Showing 10 changed files with 1,434 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
name: Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.4.2

- name: Install the package and dependencies
run: |
poetry install
- name: Run tests
run: |
poetry run make all-checks
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,45 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# MacOS
# Created by https://www.toptal.com/developers/gitignore/api/macos
# Edit at https://www.toptal.com/developers/gitignore?templates=macos

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

# End of https://www.toptal.com/developers/gitignore/api/macos

# VScode
.vscode
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
poetry-check:
@echo "🔒 Verifying that poetry.lock is consistent with pyproject.toml..."
poetry lock --check

format:
isort .
black .

format-check:
@echo "⚫ Checking code format..."
isort --check-only --diff .
black --check .

type-check:
@echo "👮 Running type checker"
mypy .

static-checks: poetry-check format-check type-check

test:
@echo "🏃 Running tests..."
pytest .

all-checks: static-checks test
@echo "✅ Great success!"

clean:
rm -rf dist

build:
poetry build
1,247 changes: 1,247 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "lightly-insights"
version = "0.1.0"
authors = ["Lightly.ai"]
description = "A tool for converting computer vision label formats."
readme = "README.md"
license = "MIT"

[tool.poetry.dependencies]
python = ">=3.7"
tqdm = "*"
pillow = "*"

[tool.poetry.group.dev.dependencies]
mypy = "*"
black = "*"
isort = "*"
flake8 = "*"
pytest = "*"
pytest-mock = "*"
build = "*"
twine = "*"
types-Pillow = "*"

# [tool.poetry.scripts]
# labelformat = "lightly_insights.cli.cli:main"

[tool.pytest.ini_options]
pythonpath = [
".", "src/"
]

[tool.isort]
profile = "black"

[tool.mypy]
ignore_missing_imports = true
python_version = 3.7
warn_unused_configs = true
strict_equality = true
# Disallow dynamic typing
#disallow_any_unimported = true # because mypy fails to follow some imports, e.g. for PIL.Image.Image and matplotlib.Figure
#disallow_any_expr = true # because intermediate expressions do not need to be typed
disallow_any_decorated = true
disallow_any_explicit = true
disallow_any_generics = true
disallow_subclassing_any = true
# Disallow untyped definitions
#disallow_untyped_calls = true # otherwise all external functions called must be typed e.g. calls to torch functions
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
# None and optional handling
no_implicit_optional = true
strict_optional = true
# Configuring warnings
warn_unused_ignores = true
warn_no_return = true
warn_return_any = true
warn_redundant_casts = true
warn_unreachable = true

# Print format
show_error_codes = true
show_error_context = true
Empty file.
2 changes: 2 additions & 0 deletions src/lightly_insights/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def main() -> None:
print("Hello, world!")
Empty file added src/lightly_insights/py.typed
Empty file.
Empty file added tests/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from lightly_insights import main


def test_main() -> None:
main.main()
assert True

0 comments on commit d126d11

Please sign in to comment.