Skip to content

Commit

Permalink
Merge pull request #275 from centre-for-humanities-computing/relaxed_…
Browse files Browse the repository at this point in the history
…upper_bounds

fix: relax upper bounds on dependencies
  • Loading branch information
KennethEnevoldsen authored Oct 10, 2023
2 parents ef87e47 + 277a1b0 commit 1931fb0
Show file tree
Hide file tree
Showing 18 changed files with 475 additions and 308 deletions.
1 change: 0 additions & 1 deletion .cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"*.github"
],
"_template": "https://github.com/MartinBernstorff/swift-python-cookiecutter",
"add_makefile": "y",
"author": "Kenneth Enevoldsen",
"copyright_year": "2023",
"email": "[email protected]",
Expand Down
3 changes: 1 addition & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/MartinBernstorff/swift-python-cookiecutter",
"commit": "691543da74e08c82a24f26eae89536b1c5581673",
"commit": "7fdb02999e8596c525377c208ca902645d134f97",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -12,7 +12,6 @@
"github_user": "centre-for-humanities-computing",
"version": "2.4.2",
"copyright_year": "2023",
"add_makefile": "y",
"license": "MIT",
"_copy_without_render": [
"*.github"
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
token: ${{ secrets.PAT }}

- name: Install dependencies
shell: bash
Expand All @@ -27,10 +28,12 @@ jobs:
uses: sphinx-notes/[email protected]
with:
documentation_path: docs
sphinx_version: "5.3.0"


- name: Push changes
if: ${{ github.event_name == 'push' }}
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.PAT }}
branch: gh-pages
98 changes: 0 additions & 98 deletions .github/workflows/mypy.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
🏎️ Get results locally by running `pre-commit run --all-files`
🕵️ Examine the results in the `Run pre-commit` section of this workflow `pre-commit`
We also strongly recommend setting up the `ruff` and `black` extensions to auto-format on save in your chosen editor.
We also recommend setting up the `ruff` and `black` extensions to auto-format on save in your chosen editor.
- name: Commit formatting
if: ${{ steps.pre_commit.outputs.pre_commit_failed == 1 && github.event_name == 'pull_request' }}
Expand Down
35 changes: 25 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@ name: Release
on:
push:
branches: [main]
workflow_run:
workflows: ["tests"]
types:
- completed

jobs:
release:
runs-on: ubuntu-latest
concurrency: release
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing using PyPI
# a guide on how to set it up is available here: https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/


if: ${{ github.ref == 'refs/heads/main' }}
if: ${{ github.ref == 'refs/heads/main' && github.event.workflow_run.conclusion == 'success'}}
steps:
# Checkout action is required for token to persist
- uses: actions/checkout@v3
Expand All @@ -22,14 +31,20 @@ jobs:
token: ${{ secrets.PAT }}

- name: Python Semantic Release
uses: relekang/[email protected]
uses: python-semantic-release/[email protected]
id: release
with:
github_token: ${{ secrets.PAT }}

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: steps.release.outputs.released == 'true'
# This action supports PyPI's trusted publishing implementation, which allows authentication to PyPI without a manually
# configured API token or username/password combination. To perform trusted publishing with this action, your project's
# publisher must already be configured on PyPI.

- name: Publish package distributions to GitHub Releases
uses: python-semantic-release/upload-to-gh-release@main
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.PAT }}
# Remember to copy the [tool.semantic_release] section from pyproject.toml
# as well
# To enable pypi,
# 1) Set upload_to_pypi to true in pyproject.toml and
# 2) Set the pypi_token in the repo
# 3) Uncomment the two lines below
repository_username: __token__
repository_password: ${{ secrets.PYPI_API_TOKEN }}
97 changes: 97 additions & 0 deletions .github/workflows/static_type_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# We do not include static_type_checks as a pre-commit hook because pre-commit hooks
# are installed in their own virtual environment, so static_type_checks cannot
# use stubs from imports
name: static_type_checks

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

jobs:
static_type_checks:
runs-on: ubuntu-latest
permissions:
pull-requests: write
concurrency:
group: "${{ github.workflow }} @ ${{ github.ref }}"
cancel-in-progress: true
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.9"]
steps:
- uses: actions/checkout@v3

- name: Cache tox
uses: actions/[email protected]
id: cache_tox
with:
path: |
.tox
key: ${{ runner.os }}-${{ matrix.python-version }}-static-type-checks

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

- name: Install dependencies
shell: bash
run: |
pip install invoke tox pyright
- name: Run static type checker
id: pyright
continue-on-error: true
run: |
if inv static-type-checks; then
echo "pyright check passed"
echo "pyright_failed=0" >> $GITHUB_OUTPUT
else
echo "pyright check failed"
echo "pyright_failed=1" >> $GITHUB_OUTPUT
fi
- name: Find Comment
uses: peter-evans/find-comment@v2
id: find_comment
if: ${{github.event_name == 'pull_request'}}
continue-on-error: true
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: ✨ Looks like pyright failed ✨

- uses: mshick/add-pr-comment@v2
if: ${{ steps.pyright.outputs.pyright_failed == 1 && github.event_name == 'pull_request'}}
id: add_comment
with:
message: |
✨ Looks like pyright failed ✨
If you want to fix this, we recommend doing it locally by either:
a) Enabling pyright in VSCode and going through the errors in the problems tab
`VSCode settings > Python > Analysis: Type checking mode > "basic"`
b) Debugging via the command line
1. Installing pyright, which is included in the dev dependencies: `pip install -e ".[dev]"`
2. Diagnosing the errors by running `pyright .`
- uses: mshick/add-pr-comment@v2
if: ${{ steps.pyright.outputs.pyright_failed == 0 && steps.find_comment.outputs.comment-id != '' && github.event_name == 'pull_request'}}
with:
message-id: ${{ steps.find_comment.outputs.comment-id }}
message: |
🌟 pyright succeeds! 🌟
- name: Show pyright output
id: fail_run
if: ${{steps.pyright.outputs.pyright_failed == 1}}
run: |
inv static-type-checks # Rerunning pyright isn't optimal computationally, but typically takes no more than a couple of seconds, and this ensures that the errors are in the failing step
19 changes: 15 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,33 @@ jobs:
steps:
- uses: actions/checkout@v3


- name: Cache tox
uses: actions/[email protected]
id: cache_tox
with:
path: |
.tox
key: ${{ runner.os }}-${{ matrix.python-version }}-tests-1

- name: Set up Python
uses: actions/setup-python@v4
id: setup_python
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies

- name: Install dependencies
shell: bash
run: |
pip install .[tests]
pip install invoke tox
- name: Run and write pytest
shell: bash
run: |
python -m pytest --durations=0 -x --junitxml=pytest.xml --cov-report=term-missing --cov=src/ tests/
# Specifying two sets of "--pytest-args" is required for invoke to parse it as a list
export DACY_CACHE_DIR=/tmp/dacy_cache
inv test --pytest-args="--durations=0" --pytest-args="--junitxml=pytest.xml --cov-report=term-missing --cov=src/"
- name: Test report on failures
uses: EnricoMi/publish-unit-test-result-action@v2
Expand All @@ -62,6 +73,6 @@ jobs:
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' && github.actor != 'dependabot[bot]' && github.event_name == 'pull_request' && (success() || failure()) }}
with:
create-new-comment: false
report-only-changed-files: true
report-only-changed-files: false
pytest-coverage-path: pytest-coverage.txt
junitxml-path: ./pytest.xml
6 changes: 3 additions & 3 deletions docs/evaluation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

from functools import partial

import dacy
import spacy
from spacy.language import Language

import dacy


def scandiner_loader() -> Language:
scandiner = spacy.blank("da")
Expand Down Expand Up @@ -117,7 +116,8 @@ def openai_model_loader_fine_ner(model: str) -> Language:
"da_core_news_md-3.5.0": partial(spacy.load, "da_core_news_md"),
"da_core_news_sm-3.5.0": partial(spacy.load, "da_core_news_sm"),
"openai/gpt-3.5-turbo (02/05/23)": partial(
openai_model_loader_simple_ner, model="gpt-3.5-turbo"
openai_model_loader_simple_ner,
model="gpt-3.5-turbo",
),
"openai/gpt-4 (02/05/23)": partial(openai_model_loader_simple_ner, model="gpt-4"),
}
Loading

0 comments on commit 1931fb0

Please sign in to comment.