Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[flake8]
max-line-length = 100
extend-ignore = E203,W503,D100,D104
per-file-ignores =
forte_api.py:D,F401,F841,E501
forte_demo.py:D,F401,E501
examples/*.py:D,E501
tests/*.py:D,F401,F811,F841
__init__.py:F401,D415
134 changes: 134 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 src/forte --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 src/forte --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics

- name: Format check with black
run: |
black --check src/forte tests

- name: Run tests with pytest
run: |
pytest tests/ -v --cov=forte --cov-report=xml --cov-report=term -m "not slow"

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Run integration tests
run: |
pytest tests/ -v -m "integration and not slow"

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Build package
run: python -m build

- name: Check package with twine
run: twine check dist/*

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

docs:
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[docs]"

- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Deploy documentation
run: mkdocs gh-deploy --force
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Project-specific
data/*
embeddings/*
*.png
*.jpg
*.jpeg

# Keep example images if needed
!docs/images/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down Expand Up @@ -149,6 +155,7 @@ venv.bak/

# mkdocs documentation
/site
site/

# mypy
.mypy_cache/
Expand All @@ -175,4 +182,4 @@ cython_debug/
.ruff_cache/

# PyPI configuration file
.pypirc
.pypirc
69 changes: 69 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
exclude: ^mkdocs\.yml$
- id: check-added-large-files
- id: check-json
- id: check-toml
- id: check-merge-conflict
- id: check-case-conflict
- id: detect-private-key
- id: mixed-line-ending
args: ['--fix=lf']
- id: name-tests-test
args: ['--pytest-test-first']

- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black
language_version: python3.9

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args: ['--max-line-length=100', '--extend-ignore=E203,W503']
additional_dependencies: [flake8-docstrings]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: [
torch,
torchvision,
transformers,
numpy,
scipy,
scikit-learn,
pillow,
tqdm,
]
args: [--config-file=pyproject.toml, --ignore-missing-imports]

- repo: https://github.com/PyCQA/bandit
rev: 1.7.6
hooks:
- id: bandit
args: ['-c', 'pyproject.toml']
additional_dependencies: ['bandit[toml]']

- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
args: ['--convention=google', '--add-ignore=D212']
exclude: '^(tests/|examples/|forte_api\.py|forte_demo\.py)'
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
- Basic evaluation metrics: AUROC, FPR@95TPR, AUPRC, F1

### Fixed
- None (initial release)
- None (initial release)
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ 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.
SOFTWARE.
28 changes: 28 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Include documentation
include README.md
include LICENSE
include CHANGELOG.md

# Include package configuration
include pyproject.toml
include setup.py

# Exclude development and build files
exclude .gitignore
exclude .git*
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
recursive-exclude * .DS_Store

# Exclude tests, docs, and examples from distribution
recursive-exclude tests *
recursive-exclude docs *
recursive-exclude examples *
recursive-exclude env *
recursive-exclude embeddings *
recursive-exclude data *

# Exclude build artifacts
recursive-exclude dist *
recursive-exclude build *
recursive-exclude *.egg-info *
Loading