Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
felixdittrich92 committed May 8, 2024
1 parent 20e6dc9 commit ddb6d74
Show file tree
Hide file tree
Showing 130 changed files with 12,871 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: 🐛 Bug report
description: Create a report to help us improve the library
labels: 'type: bug'

body:
- type: markdown
attributes:
value: >
#### Before reporting a bug, please check that the issue hasn't already been addressed in [the existing and past issues](https://github.com/mindee/onnxtr/issues?q=is%3Aissue).
- type: textarea
attributes:
label: Bug description
description: |
A clear and concise description of what the bug is.
Please explain the result you observed and the behavior you were expecting.
placeholder: |
A clear and concise description of what the bug is.
validations:
required: true

- type: textarea
attributes:
label: Code snippet to reproduce the bug
description: |
Sample code to reproduce the problem.
Please wrap your code snippet with ```` ```triple quotes blocks``` ```` for readability.
placeholder: |
```python
Sample code to reproduce the problem
```
validations:
required: true
- type: textarea
attributes:
label: Error traceback
description: |
The error message you received running the code snippet, with the full traceback.
Please wrap your error message with ```` ```triple quotes blocks``` ```` for readability.
placeholder: |
```
The error message you got, with the full traceback.
```
validations:
required: true
- type: textarea
attributes:
label: Environment
description: |
Please run the following command and paste the output below.
```sh
wget https://raw.githubusercontent.com/mindee/onnxtr/main/scripts/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```
validations:
required: true
- type: textarea
attributes:
label: Deep Learning backend
description: |
Please run the following snippet and paste the output below.
```python
from onnxtr.file_utils import is_tf_available, is_torch_available
print(f"is_tf_available: {is_tf_available()}")
print(f"is_torch_available: {is_torch_available()}")
```
validations:
required: true
- type: markdown
attributes:
value: >
Thanks for helping us improve the library!
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Usage questions
url: https://github.com/mindee/onnxtr/discussions
about: Ask questions and discuss with other OnnxTR community members
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 🚀 Feature request
description: Submit a proposal/request for a new feature for OnnxTR
labels: 'type: enhancement'

body:
- type: textarea
attributes:
label: 🚀 The feature
description: >
A clear and concise description of the feature proposal
validations:
required: true
- type: textarea
attributes:
label: Motivation, pitch
description: >
Please outline the motivation for the proposal. Is your feature request related to a specific problem? e.g., *"I'm working on X and would like Y to be possible"*. If this is related to another GitHub issue, please link here too.
validations:
required: true
- type: textarea
attributes:
label: Alternatives
description: >
A description of any alternative solutions or features you've considered, if any.
- type: textarea
attributes:
label: Additional context
description: >
Add any other context or screenshots about the feature request.
- type: markdown
attributes:
value: >
Thanks for contributing 🎉
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
open-pull-requests-limit: 10
target-branch: "main"
labels: ["topic: build"]
schedule:
interval: weekly
day: sunday
reviewers:
- "felixdittrich92"
24 changes: 24 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
changelog:
exclude:
labels:
- ignore-for-release
categories:
- title: Breaking Changes 🛠
labels:
- "type: breaking change"
# NEW FEATURES
- title: New Features
labels:
- "type: new feature"
# BUG FIXES
- title: Bug Fixes
labels:
- "type: bug"
# IMPROVEMENTS
- title: Improvements
labels:
- "type: enhancement"
# MISC
- title: Miscellaneous
labels:
- "type: misc"
87 changes: 87 additions & 0 deletions .github/verify_pr_labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Copyright (C) 2021-2024, Mindee | Felix Dittrich.

# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.

"""Borrowed & adapted from https://github.com/pytorch/vision/blob/main/.github/process_commit.py
This script finds the merger responsible for labeling a PR by a commit SHA. It is used by the workflow in
'.github/workflows/pr-labels.yml'. If there exists no PR associated with the commit or the PR is properly labeled,
this script is a no-op.
Note: we ping the merger only, not the reviewers, as the reviewers can sometimes be external to torchvision
with no labeling responsibility, so we don't want to bother them.
"""

from typing import Any, Set, Tuple

import requests

# For a PR to be properly labeled it should have one primary label and one secondary label

# Should specify the type of change
PRIMARY_LABELS = {
"type: new feature",
"type: bug",
"type: enhancement",
"type: misc",
}

# Should specify what has been modified
SECONDARY_LABELS = {
"topic: documentation",
"module: datasets",
"module: io",
"module: models",
"module: transforms",
"module: utils",
"ext: api",
"ext: demo",
"ext: docs",
"ext: notebooks",
"ext: references",
"ext: scripts",
"ext: tests",
"topic: build",
"topic: ci",
"topic: docker",
}

GH_ORG = "felixdittrich92"
GH_REPO = "onnxtr"


def query_repo(cmd: str, *, accept) -> Any:
response = requests.get(f"https://api.github.com/repos/{GH_ORG}/{GH_REPO}/{cmd}", headers=dict(Accept=accept))
return response.json()


def get_pr_merger_and_labels(pr_number: int) -> Tuple[str, Set[str]]:
# See https://docs.github.com/en/rest/reference/pulls#get-a-pull-request
data = query_repo(f"pulls/{pr_number}", accept="application/vnd.github.v3+json")
merger = data.get("merged_by", {}).get("login")
labels = {label["name"] for label in data["labels"]}
return merger, labels


def main(args):
merger, labels = get_pr_merger_and_labels(args.pr)
is_properly_labeled = bool(PRIMARY_LABELS.intersection(labels) and SECONDARY_LABELS.intersection(labels))
if isinstance(merger, str) and not is_properly_labeled:
print(f"@{merger}")


def parse_args():
import argparse

parser = argparse.ArgumentParser(
description="PR label checker", formatter_class=argparse.ArgumentDefaultsHelpFormatter
)

parser.add_argument("pr", type=int, help="PR number")
args = parser.parse_args()

return args


if __name__ == "__main__":
args = parse_args()
main(args)
72 changes: 72 additions & 0 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: builds

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

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python: ["3.9", "3.10"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v4
- if: matrix.os == 'macos-latest'
name: Install MacOS prerequisites
run: brew install cairo pango gdk-pixbuf libffi
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
architecture: x64
- if: matrix.framework == 'tensorflow'
name: Cache python modules (TF)
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}
- if: matrix.framework == 'pytorch'
name: Cache python modules (PT)
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}
- if: matrix.framework == 'tensorflow'
name: Install package (TF)
run: |
python -m pip install --upgrade pip
pip install -e .[tf,viz,html] --upgrade
- if: matrix.framework == 'pytorch'
name: Install package (PT)
run: |
python -m pip install --upgrade pip
pip install -e .[torch,viz,html] --upgrade
- name: Import package
run: python -c "import onnxtr; print(onnxtr.__version__)"

conda:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: 3.9
channels: pypdfium2-team,bblanchon,defaults,conda-forge
channel-priority: strict
- name: Install dependencies
shell: bash -el {0}
run: conda install -y conda-build conda-verify anaconda-client
- name: Build and verify
shell: bash -el {0}
run: |
python setup.py sdist
mkdir conda-dist
conda build .conda/ --output-folder conda-dist
conda-verify conda-dist/linux-64/*tar.bz2 --ignore=C1115
22 changes: 22 additions & 0 deletions .github/workflows/doc-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: doc-status
on:
page_build

jobs:
see-page-build-payload:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
architecture: x64
- name: check status
run: |
import os
status, errormsg = os.getenv('STATUS'), os.getenv('ERROR')
if status != 'built': raise AssertionError(f"There was an error building the page on GitHub pages.\n\nStatus: {status}\n\nError messsage: {errormsg}")
shell: python
env:
STATUS: ${{ github.event.build.status }}
ERROR: ${{ github.event.build.error.message }}
36 changes: 36 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: docker

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

jobs:
docker-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build docker image
run: docker build -t doctr-tf-py3.9-slim --build-arg SYSTEM=cpu .
- name: Run docker container
run: docker run doctr-tf-py3.9-slim python3 -c 'import doctr'

pytest-api:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.9"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Build & run docker
run: cd api && make lock && make run
- name: Ping server
run: wget --spider --tries=12 http://localhost:8080/docs
- name: Run docker test
run: cd api && make test
Loading

0 comments on commit ddb6d74

Please sign in to comment.