-
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.
* feat: add simple tests * feat: add test pipeline * fix: add onnxruntime to dev requirements * feat: add release pipeline
- Loading branch information
1 parent
81cd668
commit c512bbd
Showing
8 changed files
with
148 additions
and
4 deletions.
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,35 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
jobs: | ||
build: | ||
runs-on: actions-runner-cpu | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Bump version and push tag | ||
id: tag_version | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Update pyproject.toml with new version tag | ||
run: | | ||
sed -i 's/version = ".*"/version = "${{ steps.tag_version.outputs.new_tag }}"/' pyproject.toml | ||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: "[bot]: update version to ${{ steps.tag_version.outputs.new_tag }}" | ||
branch: main | ||
file_pattern: pyproject.toml | ||
add_options: --update | ||
- name: Create a GitHub release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: ${{ steps.tag_version.outputs.new_tag }} | ||
name: Release ${{ steps.tag_version.outputs.new_tag }} | ||
body: ${{ steps.tag_version.outputs.changelog }} | ||
generateReleaseNotes: true |
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,35 @@ | ||
name: Run Focoos tests | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
AWS_REGION: eu-west-1 | ||
jobs: | ||
Run-test: | ||
runs-on: actions-runner-cpu | ||
permissions: | ||
id-token: write # This is required for requesting the JWT | ||
contents: read | ||
issues: write | ||
pull-requests: write | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: install make | ||
run: sudo apt-get update && sudo apt-get install ffmpeg libsm6 libxext6 make -y | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.12" | ||
cache: "pip" | ||
- name: Install dependencies | ||
run: make install-dev | ||
- name: Run test | ||
run: make test | ||
- name: Pytest coverage comment | ||
uses: MishaKav/pytest-coverage-comment@main | ||
with: | ||
pytest-xml-coverage-path: ./tests/coverage.xml | ||
junitxml-path: ./tests/junit.xml | ||
report-only-changed-files: true |
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 |
---|---|---|
|
@@ -88,3 +88,4 @@ ipython_config.py | |
notebooks/.data | ||
.venv | ||
/data | ||
tests/junit.xml |
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
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ include = ["focoos**"] | |
|
||
[project] | ||
name = "focoos" | ||
version = "0.0.1" | ||
description = "Focoos SDK" | ||
readme = "README.md" | ||
requires-python = ">=3.10" | ||
|
@@ -20,7 +21,7 @@ dependencies = [ | |
"numpy~=1.26.4", | ||
"scipy~=1.14.1", | ||
] | ||
version = "0.0.1" | ||
|
||
authors = [{ name = "focoos.ai", email = "[email protected]" }] | ||
keywords = [ | ||
"computer_vision", | ||
|
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,70 @@ | ||
import pytest | ||
from unittest.mock import patch, MagicMock | ||
from focoos.ports import ModelMetadata, DatasetMetadata, ModelPreview | ||
from focoos.focoos import Focoos | ||
from focoos.utils.system import HttpClient | ||
|
||
|
||
@pytest.fixture | ||
def focoos_instance(): | ||
with patch("focoos.focoos.HttpClient") as MockHttpClient: | ||
mock_client = MockHttpClient.return_value | ||
mock_client.get.return_value.status_code = 200 | ||
mock_client.get.return_value.json.return_value = {"email": "[email protected]"} | ||
return Focoos(api_key="test_api_key", host_url="http://mock-host-url.com") | ||
|
||
|
||
def test_focoos_initialization(focoos_instance): | ||
assert focoos_instance.api_key == "test_api_key" | ||
assert focoos_instance.user_info["email"] == "[email protected]" | ||
|
||
|
||
def test_get_model_info(focoos_instance): | ||
mock_response = { | ||
"name": "test-model", | ||
"ref": "model-ref", | ||
"owner_ref": "pytest", | ||
"focoos_model": "focoos_rtdetr", | ||
"created_at": "2024-01-01", | ||
"updated_at": "2024-01-01", | ||
"description": "Test model description", | ||
"task": "detection", | ||
"status": "TRAINING_COMPLETED", | ||
} | ||
focoos_instance.http_client.get = MagicMock( | ||
return_value=MagicMock(status_code=200, json=lambda: mock_response) | ||
) | ||
model_info = focoos_instance.get_model_info("test-model") | ||
assert model_info.name == "test-model" | ||
assert model_info.ref == "model-ref" | ||
assert model_info.description == "Test model description" | ||
|
||
|
||
def test_list_models(focoos_instance): | ||
mock_response = [ | ||
{ | ||
"name": "model1", | ||
"ref": "ref1", | ||
"task": "detection", | ||
"description": "model1 description", | ||
"status": "TRAINING_COMPLETED", | ||
"focoos_model": "focoos_rtdetr", | ||
}, | ||
{ | ||
"name": "model2", | ||
"ref": "ref2", | ||
"task": "detection", | ||
"description": "model2 description", | ||
"status": "TRAINING_RUNNING", | ||
"focoos_model": "focoos_rtdetr", | ||
}, | ||
] | ||
|
||
focoos_instance.http_client.get = MagicMock( | ||
return_value=MagicMock(status_code=200, json=lambda: mock_response) | ||
) | ||
|
||
models = focoos_instance.list_models() | ||
assert len(models) == 2 | ||
assert models[0].name == "model1" | ||
assert models[1].ref == "ref2" |