Skip to content

Commit 68817c4

Browse files
Merge pull request #1824 from VWS-Python/test-readme
Test code in README
2 parents 7582ad5 + 559073d commit 68817c4

File tree

4 files changed

+107
-72
lines changed

4 files changed

+107
-72
lines changed

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
[![Build
2+
Status](https://github.com/VWS-Python/vws-python/workflows/CI/badge.svg)](https://github.com/VWS-Python/vws-python/actions)
3+
[![codecov](https://codecov.io/gh/VWS-Python/vws-python/branch/master/graph/badge.svg)](https://codecov.io/gh/VWS-Python/vws-python)
4+
[![PyPI](https://badge.fury.io/py/VWS-Python.svg)](https://badge.fury.io/py/VWS-Python)
5+
[![Documentation Status](https://readthedocs.org/projects/vws-python/badge/?version=latest)](https://vws-python.readthedocs.io/en/latest/?badge=latest)
6+
7+
# vws-python
8+
9+
Python library for the Vuforia Web Services (VWS) API and the Vuforia
10+
Web Query API.
11+
12+
## Installation
13+
14+
```sh
15+
pip install vws-python
16+
```
17+
18+
This is tested on Python 3.11+. Get in touch with
19+
`adamdangoor@gmail.com` if you would like to use this with another
20+
language.
21+
22+
## Getting Started
23+
24+
<!--
25+
```python
26+
import pathlib
27+
import shutil
28+
29+
import vws_test_fixtures
30+
from mock_vws import MockVWS
31+
from mock_vws.database import VuforiaDatabase
32+
33+
mock = MockVWS(real_http=False)
34+
database = VuforiaDatabase(
35+
server_access_key='[server-access-key]',
36+
server_secret_key='[server-secret-key]',
37+
client_access_key='[client-access-key]',
38+
client_secret_key='[client-secret-key]',
39+
)
40+
mock.add_database(database=database)
41+
mock.__enter__()
42+
43+
# We rely on implementation details of the fixtures package.
44+
image = pathlib.Path(vws_test_fixtures.__path__[0]) / 'high_quality_image.jpg'
45+
assert image.exists(), image.resolve()
46+
new_image = pathlib.Path('high_quality_image.jpg')
47+
shutil.copy(image, new_image)
48+
```
49+
-->
50+
51+
<!--pytest-codeblocks:cont-->
52+
53+
```python
54+
import io
55+
import pathlib
56+
57+
from vws import VWS, CloudRecoService
58+
59+
server_access_key = '[server-access-key]'
60+
server_secret_key = '[server-secret-key]'
61+
client_access_key = '[client-access-key]'
62+
client_secret_key = '[client-secret-key]'
63+
64+
vws_client = VWS(
65+
server_access_key=server_access_key,
66+
server_secret_key=server_secret_key,
67+
)
68+
cloud_reco_client = CloudRecoService(
69+
client_access_key=client_access_key,
70+
client_secret_key=client_secret_key,
71+
)
72+
name = 'my_image_name'
73+
74+
image = pathlib.Path('high_quality_image.jpg')
75+
with image.open(mode='rb') as my_image_file:
76+
my_image = io.BytesIO(my_image_file.read())
77+
78+
target_id = vws_client.add_target(
79+
name=name,
80+
width=1,
81+
image=my_image,
82+
active_flag=True,
83+
application_metadata=None,
84+
)
85+
vws_client.wait_for_target_processed(target_id=target_id)
86+
matching_targets = cloud_reco_client.query(image=my_image)
87+
88+
assert matching_targets[0].target_id == target_id
89+
```
90+
91+
<!--pytest-codeblocks:cont-->
92+
93+
<!--
94+
```python
95+
new_image = pathlib.Path('high_quality_image.jpg')
96+
new_image.unlink()
97+
mock.__exit__()
98+
```
99+
-->
100+
101+
## Full Documentation
102+
103+
See the [full
104+
documentation](https://vws-python.readthedocs.io/en/latest).

README.rst

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

lint.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ spelling:
6161
.PHONY: doctest
6262
doctest:
6363
$(MAKE) -C docs/ doctest SPHINXOPTS=$(SPHINXOPTS)
64+
pytest --codeblocks README.md

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ dynamic = ["version"]
218218
keywords = ["vuforia", "vws", "client"]
219219
license = { file = "LICENSE" }
220220
name = "vws-python"
221-
readme = { file = "README.rst", content-type = "text/x-rst"}
221+
readme = { file = "README.md", content-type = "text/markdown"}
222222
requires-python = ">=3.10"
223223
dependencies = [
224224
"VWS-Auth-Tools",
@@ -249,6 +249,7 @@ dev = [
249249
"pylint==2.17.0 ",
250250
"pyroma==4.2",
251251
"pytest-cov==4.0.0",
252+
"pytest_codeblocks==0.16.1",
252253
"pytest==7.2.2 ",
253254
"ruff==0.0.255",
254255
"sphinx-autodoc-typehints==1.22",

0 commit comments

Comments
 (0)