Skip to content

Commit 6f38ea9

Browse files
committed
test(instill): improve unit test coverage (#287)
Because - the unit test coverage was pretty poor and the structure wasn't organized well This commit - improved the unit test coverage
1 parent 4b122cf commit 6f38ea9

27 files changed

+1875
-218
lines changed

β€Ž.coveragercβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ omit =
88
.venv/*
99
*/tests/*
1010
*/__main__.py
11+
instill/protogen/*
1112

1213
[report]
1314

β€Ž.github/CONTRIBUTING.mdβ€Ž

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ Before delving into the details to come up with your first PR, please familiaris
2727

2828
To confirm these system dependencies are configured correctly:
2929

30-
```shell
31-
make doctor
32-
```
33-
3430
#### Installation
3531

3632
Fetch git submodules:

β€Ž.github/workflows/build.ymlβ€Ž

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ jobs:
2323
with:
2424
poetry-version: 2.1.2
2525

26-
- name: Check dependencies
27-
run: make doctor
28-
2926
- uses: actions/cache@v4
3027
with:
3128
path: .venv

β€Ž.github/workflows/publish.ymlβ€Ž

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ jobs:
1818
- name: Set up Python
1919
uses: actions/setup-python@v4
2020
with:
21-
python-version: "3.11"
21+
python-version: "3.12"
2222

23-
- uses: Gr1N/setup-poetry@v8
24-
25-
- name: Check dependencies
26-
run: make doctor
23+
- uses: abatilo/actions-poetry@v4
24+
with:
25+
poetry-version: 2.1.2
2726

2827
- uses: actions/cache@v3
2928
with:

β€ŽMakefileβ€Ž

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ PYTEST_OPTIONS += --cov-report=xml
6767
endif
6868
PYTEST_RERUN_OPTIONS := --last-failed --exitfirst
6969

70-
.PHONY: test
71-
test: test-all ## Run unit and integration tests
72-
7370
.PHONY: test-unit
7471
test-unit: install
7572
@ ( mv $(FAILURES) $(FAILURES).bak || true ) > /dev/null 2>&1
@@ -79,23 +76,8 @@ ifndef DISABLE_COVERAGE
7976
poetry run coveragespace update unit
8077
endif
8178

82-
.PHONY: test-int
83-
test-int: install
84-
@ if test -e $(FAILURES); then poetry run pytest tests $(PYTEST_RERUN_OPTIONS); fi
85-
@ rm -rf $(FAILURES)
86-
poetry run pytest tests $(PYTEST_OPTIONS)
87-
ifndef DISABLE_COVERAGE
88-
poetry run coveragespace update integration
89-
endif
90-
91-
.PHONY: test-all
92-
test-all: install
93-
@ if test -e $(FAILURES); then poetry run pytest $(PACKAGE) tests $(PYTEST_RERUN_OPTIONS); fi
94-
@ rm -rf $(FAILURES)
95-
poetry run pytest $(PACKAGE) tests $(PYTEST_OPTIONS)
96-
ifndef DISABLE_COVERAGE
97-
poetry run coveragespace update overall
98-
endif
79+
.PHONY: test
80+
test: test-unit
9981

10082
.PHONY: read-coverage
10183
read-coverage:
@@ -105,18 +87,18 @@ read-coverage:
10587

10688
.PHONY: format
10789
format: install
108-
poetry run isort $(PACKAGE) tests notebooks
109-
poetry run black $(PACKAGE) tests notebooks
90+
poetry run isort $(PACKAGE) notebooks
91+
poetry run black $(PACKAGE) notebooks
11092
@ echo
11193

11294
.PHONY: check
11395
check: install format ## Run formatters, linters, and static analysis
11496
ifdef CI
11597
git diff --exit-code
11698
endif
117-
poetry run mypy $(PACKAGE) tests
118-
poetry run pylint $(PACKAGE) tests --rcfile=.pylint.ini
119-
poetry run pydocstyle $(PACKAGE) tests
99+
poetry run mypy $(PACKAGE)
100+
poetry run pylint $(PACKAGE) --rcfile=.pylint.ini
101+
poetry run pydocstyle $(PACKAGE)
120102

121103
# DOCUMENTATION ###############################################################
122104

@@ -195,7 +177,7 @@ clean-all: clean
195177

196178
.PHONY: .clean-install
197179
.clean-install:
198-
find $(PACKAGE) tests -name '__pycache__' -delete
180+
find $(PACKAGE) -name '__pycache__' -delete
199181
rm -rf *.egg-info
200182

201183
.PHONY: .clean-test

β€ŽREADME.mdβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Instill Core Python SDK
22

3-
[![Unix Build Status](https://img.shields.io/github/actions/workflow/status/instill-ai/python-sdk/build.yml?branch=main&label=linux)](https://github.com/instill-ai/python-sdk/actions) [![Coverage Status](https://img.shields.io/codecov/c/gh/instill-ai/python-sdk)](https://codecov.io/gh/instill-ai/python-sdk) [![PyPI License](https://img.shields.io/pypi/l/instill-sdk.svg?color=lightgreen)](https://pypi.org/project/instill-sdk) [![PyPI Version](https://img.shields.io/pypi/v/instill-sdk.svg?color=lightgreen)](https://pypi.org/project/instill-sdk) [![PyPI Downloads](https://img.shields.io/pypi/dm/instill-sdk.svg?color=lightgreen)](https://pypistats.org/packages/instill-sdk)
3+
[![Unix Build Status](https://img.shields.io/github/actions/workflow/status/instill-ai/python-sdk/build.yml?branch=main&label=linux)](https://github.com/instill-ai/python-sdk/actions) [![Coverage Status](https://img.shields.io/codecov/c/gh/instill-ai/python-sdk)](https://codecov.io/gh/instill-ai/python-sdk) [![PyPI License](https://img.shields.io/pypi/l/instill-sdk.svg?color=blue)](https://pypi.org/project/instill-sdk) [![PyPI Version](https://img.shields.io/pypi/v/instill-sdk.svg?color=blue)](https://pypi.org/project/instill-sdk) [![PyPI Downloads](https://img.shields.io/pypi/dm/instill-sdk.svg?color=blue)](https://pypistats.org/packages/instill-sdk)
44

55
> [!IMPORTANT]
66
> **This SDK tool is under active development**
@@ -103,7 +103,7 @@ hosts:
103103
If you do not like the idea of having to create a config file, you can also setup your target instance by doing the following at the very beginning of your script.
104104
105105
```python
106-
from instill.configuration import global_config
106+
from instill.config import global_config
107107

108108
global_config.set_default(
109109
url="api.instill-ai.com",

β€Žinstill/clients/constant.pyβ€Ž

Lines changed: 0 additions & 1 deletion
This file was deleted.

β€Žinstill/configuration/__init__.pyβ€Ž renamed to β€Žinstill/config/__init__.pyβ€Ž

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ def load(self) -> None:
4848
return
4949
try:
5050
with open(path, "r", encoding="utf-8") as c:
51-
self._config = _Config.validate(yaml.load(c, Loader=yaml.FullLoader))
51+
self._config = _Config.model_validate(
52+
yaml.load(c, Loader=yaml.FullLoader)
53+
)
5254
except Exception as e:
5355
raise BaseException(f"Invalid configuration file at '{path}'") from e
5456

@@ -60,7 +62,7 @@ def save(self) -> None:
6062
with open(path, "w", encoding="utf-8") as c:
6163
yaml.dump(
6264
json.loads(
63-
self._config.json(
65+
self._config.model_dump_json(
6466
exclude_none=True,
6567
)
6668
),

β€Žinstill/helpers/test.pyβ€Ž

Lines changed: 0 additions & 25 deletions
This file was deleted.

β€Žinstill/resources/const.pyβ€Ž

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
Β (0)