-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Inital Project Setup * Inital Project Setup * Inital Project Setup * Inital Project Setup * Inital Project Setup * Inital Project Setup * Inital Project Setup * Inital Project Setup * Inital Project Setup * Inital Project Setup * Update setup.py Co-authored-by: Jeff Yang <[email protected]> Co-authored-by: Jeff Yang <[email protected]>
- Loading branch information
1 parent
82d64af
commit 5c709d8
Showing
22 changed files
with
381 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# https://docs.codecov.io/docs/codecovyml-reference | ||
codecov: | ||
bot: "codecov-io" | ||
strict_yaml_branch: "yaml-config" | ||
require_ci_to_pass: yes | ||
notify: | ||
after_n_builds: 16 | ||
wait_for_ci: yes | ||
# https://docs.codecov.io/docs/codecov-yaml#section-expired-reports | ||
max_report_age: off | ||
|
||
coverage: | ||
precision: 0 # 2 = xx.xx%, 0 = xx% | ||
round: nearest # how coverage is rounded: down/up/nearest | ||
range: 40...100 # custom range of coverage colors from red -> yellow -> green | ||
status: | ||
# https://codecov.readme.io/v1.0/docs/commit-status | ||
project: | ||
default: | ||
against: auto | ||
target: 96% # specify the target coverage for each commit status | ||
threshold: 30% # allow this little decrease on project | ||
# https://github.com/codecov/support/wiki/Filtering-Branches | ||
# branches: master | ||
if_ci_failed: error | ||
# https://github.com/codecov/support/wiki/Patch-Status | ||
patch: | ||
default: | ||
against: auto | ||
target: 50% # specify the target "X%" coverage to hit | ||
# threshold: 50% # allow this much decrease on patch | ||
changes: false | ||
|
||
parsers: | ||
gcov: | ||
branch_detection: | ||
conditional: true | ||
loop: true | ||
macro: false | ||
method: false | ||
javascript: | ||
enable_partials: false | ||
|
||
comment: | ||
layout: header, diff | ||
require_changes: false | ||
behavior: default # update if exists else create new | ||
after_n_builds: 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[flake8] | ||
max-line-length=88 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: ci_code_quality | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
jobs: | ||
code_quality: | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.6 | ||
|
||
- run: pip install wheel pip setuptools -U | ||
# - run: pip install ".[dev]" --progress-bar off -Uf https://download.pytorch.org/whl/cpu/torch_stable.html | ||
- run: echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV | ||
|
||
- uses: github/codeql-action/init@v1 | ||
with: | ||
languages: python | ||
setup-python-dependencies: false | ||
|
||
- uses: github/codeql-action/analyze@v1 | ||
- run: bash ./scripts/run_code_quality.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: ci_unittest | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
|
||
jobs: | ||
unittest: | ||
runs-on: ubuntu-18.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python_version: [3.6, 3.7, 3.8] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python_version }} | ||
|
||
- run: echo "::set-output name=date::$(/bin/date "+%Y-%U")" | ||
id: get-date | ||
|
||
- run: echo "::set-output name=dir::$(pip cache dir)" | ||
id: pip-cache | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
${{ steps.pip-cache.outputs.dir }} | ||
key: ${{ steps.get-date.outputs.date }}-py${{ matrix.python_version }} | ||
restore-keys: | | ||
${{ steps.get-date.outputs.date }}-py${{ matrix.python_version }} | ||
${{ steps.get-date.outputs.date }}-py | ||
- run: pip install wheel pip setuptools -U | ||
# - run: pip install ".[testing]" --progress-bar off -Uf https://download.pytorch.org/whl/cpu/torch_stable.html | ||
# - run: bash ./scripts/run_tests.sh | ||
env: | ||
TORCH_UTILS_COLLECT_ENV: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"python.pythonPath": "~/miniconda3/envs/detection/bin/python", | ||
"python.linting.pylintEnabled": true, | ||
"python.linting.flake8Enabled": true, | ||
"python.formatting.provider": "black", | ||
"python.formatting.blackPath": "~/miniconda3/envs/detection/bin/black", | ||
"python.linting.flake8Path": "~/miniconda3/envs/detection/bin/flake8", | ||
"python.linting.pylintPath": "~/miniconda3/envs/detection/bin/pylint", | ||
"python.testing.unittestArgs": ["-v", "-s", "./tests", "-p", "test_*.py"], | ||
"python.testing.pytestEnabled": false, | ||
"python.testing.nosetestsEnabled": false, | ||
"python.testing.unittestEnabled": true | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from fastapi import APIRouter | ||
|
||
from api.endpoints import detections | ||
|
||
api_router = APIRouter() | ||
api_router.include_router(detections.router, tags=["detections"]) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from typing import Any, List | ||
|
||
from fastapi import APIRouter | ||
|
||
router = APIRouter() | ||
|
||
# http://0.0.0.0:8000/api/v1/ | ||
@router.get('/') | ||
async def detect(): | ||
return { | ||
"message": "Hello World" | ||
} | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import secrets | ||
from typing import Any, Dict, List, Optional, Union | ||
|
||
from pydantic import AnyHttpUrl, BaseSettings, HttpUrl | ||
|
||
class Settings(BaseSettings): | ||
API_V1_STR: str = "/api/v1" | ||
SECRET_KEY: str = secrets.token_urlsafe(32) | ||
# 60 minutes * 24 hours * 7 days = 7 days | ||
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7 | ||
# SERVER_NAME: str | ||
# SERVER_HOST: AnyHttpUrl | ||
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = [] | ||
|
||
PROJECT_NAME: str = "DL API" | ||
|
||
class Config: | ||
case_sensitive = True | ||
|
||
|
||
settings = Settings() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import uvicorn | ||
|
||
from fastapi import FastAPI | ||
from fastapi.middleware.cors import CORSMiddleware | ||
|
||
from core.config import settings | ||
|
||
from api.api import api_router | ||
|
||
app = FastAPI( | ||
title=settings.PROJECT_NAME, openapi_prefix=f"{settings.API_V1_STR}/openapi.json" | ||
) | ||
|
||
if settings.BACKEND_CORS_ORIGINS: | ||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_origins=[str(origin) for origin in settings.BACKEND_CORS_ORIGINS], | ||
allow_credentials=True, | ||
allow_methods=["*"], | ||
allow_headers=["*"] | ||
) | ||
|
||
|
||
app.include_router(api_router, prefix=settings.API_V1_STR) | ||
|
||
if __name__ == "__main__": | ||
uvicorn.run(app, host="0.0.0.0", port=8000) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# conda / mamba env update -f environment.yml | ||
|
||
name: package | ||
|
||
channels: | ||
- pytorch | ||
- conda-forge | ||
|
||
dependencies: | ||
- python=3.8 | ||
- cpuonly | ||
- pip | ||
- numpy | ||
- pytorch | ||
- ignite | ||
- pytorch-lightning | ||
|
||
- pip: | ||
- fastapi | ||
- uvicorn | ||
- python-multipart | ||
- prettytable | ||
- coverage | ||
- parameterized |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
|
||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: "" | ||
hooks: | ||
- id: prettier | ||
|
||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.5.3 | ||
hooks: | ||
- id: isort | ||
|
||
- repo: https://gitlab.com/PyCQA/flake8 | ||
rev: 3.8.3 | ||
hooks: | ||
- id: flake8 | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 20.8b1 | ||
hooks: | ||
- id: black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# ------------ | ||
# black config | ||
# ------------ | ||
[tool.black] | ||
line-length = 88 | ||
target-version = ['py36', 'py37', 'py38'] | ||
include = '\.pyi?$' | ||
exclude = ''' | ||
( | ||
/( | ||
\.eggs # exclude a few common directories in the | ||
| \.git # root of the project | ||
| \.hg | ||
| \.mypy_cache | ||
| \.tox | ||
| \.venv | ||
| _build | ||
| buck-out | ||
| build | ||
| dist | ||
| assets | ||
)/ | ||
| foo.py # also separately exclude a file named foo.py in | ||
# the root of the project | ||
) | ||
''' | ||
|
||
# ------------ | ||
# isort config | ||
# ------------ | ||
[tool.isort] | ||
profile="black" | ||
|
||
# ------------- | ||
# pylint config | ||
# ------------- | ||
[tool.pylint.reports] | ||
output-format="colorized" | ||
reports="yes" | ||
|
||
[tool.pylint.typecheck] | ||
generated-members="numpy.*,torch.*,cv2.*,np.*" | ||
|
||
[tool.pylint.design] | ||
max-args=6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -xu | ||
|
||
black . --check | ||
|
||
flake8 . --config .flake8 | ||
|
||
isort . --color --check | ||
|
||
pylint toydet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
#!/bin/bash | ||
|
||
set -xu | ||
|
||
if [[ "${TORCH_UTILS_COLLECT_ENV}" -eq 1 ]]; then | ||
python -m torch.utils.collect_env | ||
fi | ||
|
||
# coverage run --source toydet -m unittest discover -bv -s ./tests/ -p "test_*.py" && coverage report |
Oops, something went wrong.