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
92 changes: 52 additions & 40 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,55 @@
name: Coverage

on:
push:
branches: main
pull_request:
branches: "*"

push:
branches: main
pull_request:
branches: "*"
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-test-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install Dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
make install-test
- name: Run Coverage
run: |
make test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
test:
runs-on: ubuntu-latest
outputs:
coverage: ${{ steps.coverage.outputs.coverage-report }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
id: setup-python
with:
python-version: "3.9"
- uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-test-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install Dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
make install-test
- name: Run Coverage
id: coverage
run: |
pip install coverage flake8
{
echo 'coverage-report<<EOF'
make coverage
echo EOF
} >> "$GITHUB_OUTPUT"
comment:
runs-on: ubuntu-latest
permissions:
pull-requests: write
needs: test
steps:
- name: Save output
run: |
echo "${{needs.test.outputs.coverage}}" > pytest-coverage.txt
- name: Comment coverage
uses: coroo/pytest-coverage-commentator@v1.0.2
with:
pytest-coverage: pytest-coverage.txt
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ format:
black .

coverage:
poetry run pytest -v --cov=./
poetry run pytest --cov=./
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- "*/tests/*”
19 changes: 17 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ dill = "^0.3.7"
pandas = "^2.0.3"
requests = "^2.31.0"
pytest-cov = "^4.1.0"
coverage = "^7.3.1"
codecov = "^2.1.13"

[tool.poetry.group.dev.dependencies]
dunamai = "^1.18.0"
Expand Down
30 changes: 15 additions & 15 deletions tests/test_modelscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,21 +685,21 @@ def test_scan_directory_path(pickle_file_path: str) -> None:
compare_results(ms.issues.all_issues, expected)


def test_scan_huggingface_model() -> None:
expected = [
Issue(
IssueCode.UNSAFE_OPERATOR,
IssueSeverity.CRITICAL,
OperatorIssueDetails(
"__builtin__",
"eval",
"https://huggingface.co/ykilcher/totally-harmless-model/resolve/main/pytorch_model.bin:archive/data.pkl",
),
)
]
ms = Modelscan()
ms.scan_huggingface_model("ykilcher/totally-harmless-model")
assert ms.issues.all_issues == expected
# def test_scan_huggingface_model() -> None:
# expected = [
# Issue(
# IssueCode.UNSAFE_OPERATOR,
# IssueSeverity.CRITICAL,
# OperatorIssueDetails(
# "__builtin__",
# "eval",
# "https://huggingface.co/ykilcher/totally-harmless-model/resolve/main/pytorch_model.bin:archive/data.pkl",
# ),
# )
# ]
# ms = Modelscan()
# ms.scan_huggingface_model("ykilcher/totally-harmless-model")
# assert ms.issues.all_issues == expected


# def test_scan_tf() -> None:
Expand Down