Skip to content
This repository was archived by the owner on Oct 30, 2026. It is now read-only.

Commit 54861ff

Browse files
committed
Remove Cloud Image Recognition clients and models
1 parent 58612ab commit 54861ff

42 files changed

Lines changed: 94 additions & 7488 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.rst‎

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
vws-python
44
==========
55

6-
Python library for the Vuforia Web Services (VWS) API and the Vuforia Web Query API.
6+
Python clients for the Vuforia Model Target Web API and VuMark generation.
77

88
Installation
99
------------
@@ -20,47 +20,23 @@ Getting Started
2020

2121
.. code-block:: python
2222
23-
"""Add a target to VWS and then query it."""
23+
"""Generate a VuMark instance."""
2424
2525
import os
26-
import pathlib
27-
import uuid
2826
29-
from vws import VWS, CloudRecoService
27+
from vws import VuMarkService
28+
from vws.vumark_accept import VuMarkAccept
3029
31-
server_access_key = os.environ["VWS_SERVER_ACCESS_KEY"]
32-
server_secret_key = os.environ["VWS_SERVER_SECRET_KEY"]
33-
client_access_key = os.environ["VWS_CLIENT_ACCESS_KEY"]
34-
client_secret_key = os.environ["VWS_CLIENT_SECRET_KEY"]
35-
36-
vws_client = VWS(
37-
server_access_key=server_access_key,
38-
server_secret_key=server_secret_key,
30+
client = VuMarkService(
31+
server_access_key=os.environ["VWS_SERVER_ACCESS_KEY"],
32+
server_secret_key=os.environ["VWS_SERVER_SECRET_KEY"],
3933
)
40-
41-
cloud_reco_client = CloudRecoService(
42-
client_access_key=client_access_key,
43-
client_secret_key=client_secret_key,
34+
image = client.generate_vumark_instance(
35+
target_id=os.environ["VUMARK_TARGET_ID"],
36+
instance_id="123",
37+
accept=VuMarkAccept.PNG,
4438
)
45-
46-
name = "my_image_name_" + uuid.uuid4().hex
47-
48-
image = pathlib.Path("high_quality_image.jpg")
49-
with image.open(mode="rb") as my_image_file:
50-
target_id = vws_client.add_target(
51-
name=name,
52-
width=1,
53-
image=my_image_file,
54-
active_flag=True,
55-
application_metadata=None,
56-
)
57-
58-
vws_client.wait_for_target_processed(target_id=target_id)
59-
60-
with image.open(mode="rb") as my_image_file:
61-
matching_targets = cloud_reco_client.query(image=my_image_file)
62-
63-
assert matching_targets[0].target_id == target_id
39+
assert image.startswith(b"\x89PNG")
6440
6541
Full Documentation
6642
------------------

‎conftest.py‎

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
from __future__ import annotations
44

5-
import io
65
import uuid
76
from collections.abc import Generator
87
from doctest import ELLIPSIS
9-
from pathlib import Path
108

119
import pytest
1210
from mock_vws import MockVWS
13-
from mock_vws.database import CloudDatabase
11+
from mock_vws.database import VuMarkDatabase
12+
from mock_vws.target import VuMarkTarget
1413
from sybil import Sybil
1514
from sybil.parsers.rest import (
1615
ClearNamespaceParser,
@@ -19,22 +18,6 @@
1918
)
2019

2120

22-
@pytest.fixture(name="make_image_file")
23-
def fixture_make_image_file(
24-
*,
25-
high_quality_image: io.BytesIO,
26-
) -> Generator[None]:
27-
"""Make an image file available in the test directory.
28-
29-
The path of this file matches the path in the documentation.
30-
"""
31-
new_image = Path("high_quality_image.jpg")
32-
buffer = high_quality_image.getvalue()
33-
_ = new_image.write_bytes(data=buffer)
34-
yield
35-
new_image.unlink()
36-
37-
3821
@pytest.fixture(name="mock_vws")
3922
def fixture_mock_vws(
4023
*,
@@ -46,23 +29,17 @@ def fixture_mock_vws(
4629
"""
4730
server_access_key = uuid.uuid4().hex
4831
server_secret_key = uuid.uuid4().hex
49-
client_access_key = uuid.uuid4().hex
50-
client_secret_key = uuid.uuid4().hex
51-
database_id = uuid.uuid4().hex
32+
target = VuMarkTarget(name="example-template")
5233

53-
database = CloudDatabase(
34+
database = VuMarkDatabase(
5435
server_access_key=server_access_key,
5536
server_secret_key=server_secret_key,
56-
client_access_key=client_access_key,
57-
client_secret_key=client_secret_key,
58-
database_id=database_id,
37+
vumark_targets={target},
5938
)
6039

6140
monkeypatch.setenv(name="VWS_SERVER_ACCESS_KEY", value=server_access_key)
6241
monkeypatch.setenv(name="VWS_SERVER_SECRET_KEY", value=server_secret_key)
63-
monkeypatch.setenv(name="VWS_CLIENT_ACCESS_KEY", value=client_access_key)
64-
monkeypatch.setenv(name="VWS_CLIENT_SECRET_KEY", value=client_secret_key)
65-
monkeypatch.setenv(name="VWS_DATABASE_ID", value=database_id)
42+
monkeypatch.setenv(name="VUMARK_TARGET_ID", value=target.target_id)
6643
# The mock accepts one hard-coded pair of Model Target Web API OAuth2
6744
# credentials, which it does not expose.
6845
monkeypatch.setenv(
@@ -75,7 +52,7 @@ def fixture_mock_vws(
7552
)
7653
# We use a low processing time so that tests run quickly.
7754
with MockVWS(processing_time_seconds=0.2) as mock:
78-
mock.add_cloud_database(cloud_database=database)
55+
mock.add_vumark_database(vumark_database=database)
7956
yield
8057

8158

@@ -86,5 +63,5 @@ def fixture_mock_vws(
8663
PythonCodeBlockParser(),
8764
],
8865
patterns=["*.rst", "*.py"],
89-
fixtures=["make_image_file", "mock_vws"],
66+
fixtures=["mock_vws"],
9067
).pytest()

‎docs/source/api-reference.rst‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ API Reference
55
:undoc-members:
66
:members:
77

8-
.. automodule:: vws.async_vws
9-
:undoc-members:
10-
:members:
11-
12-
.. automodule:: vws.async_query
13-
:undoc-members:
14-
:members:
15-
168
.. automodule:: vws.async_vumark_service
179
:undoc-members:
1810
:members:
@@ -37,10 +29,6 @@ API Reference
3729
:undoc-members:
3830
:members:
3931

40-
.. automodule:: vws.include_target_data
41-
:undoc-members:
42-
:members:
43-
4432
.. automodule:: vws.vumark_accept
4533
:undoc-members:
4634
:members:

‎docs/source/exceptions.rst‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@ VWS exceptions
1919
:inherited-members: Exception
2020
:exclude-members: errno, filename, filename2, strerror
2121

22-
CloudRecoService exceptions
23-
---------------------------
24-
25-
.. automodule:: vws.exceptions.cloud_reco_exceptions
26-
:members:
27-
:show-inheritance:
28-
:inherited-members: Exception
29-
:exclude-members: errno, filename, filename2, strerror
30-
3122
ModelTargetService exceptions
3223
-----------------------------
3324

‎docs/source/index.rst‎

Lines changed: 12 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -18,97 +18,23 @@ See the :doc:`api-reference` for full usage details.
1818

1919
.. code-block:: python
2020
21-
"""Add a target to VWS and then query it."""
21+
"""Generate a VuMark instance."""
2222
2323
import os
24-
import pathlib
25-
import uuid
2624
27-
from vws import VWS, CloudRecoService
25+
from vws import VuMarkService
26+
from vws.vumark_accept import VuMarkAccept
2827
29-
server_access_key = os.environ["VWS_SERVER_ACCESS_KEY"]
30-
server_secret_key = os.environ["VWS_SERVER_SECRET_KEY"]
31-
client_access_key = os.environ["VWS_CLIENT_ACCESS_KEY"]
32-
client_secret_key = os.environ["VWS_CLIENT_SECRET_KEY"]
33-
34-
vws_client = VWS(
35-
server_access_key=server_access_key,
36-
server_secret_key=server_secret_key,
37-
)
38-
39-
cloud_reco_client = CloudRecoService(
40-
client_access_key=client_access_key,
41-
client_secret_key=client_secret_key,
42-
)
43-
44-
name = "my_image_name_" + uuid.uuid4().hex
45-
46-
image = pathlib.Path("high_quality_image.jpg")
47-
with image.open(mode="rb") as my_image_file:
48-
target_id = vws_client.add_target(
49-
name=name,
50-
width=1,
51-
image=my_image_file,
52-
active_flag=True,
53-
application_metadata=None,
54-
)
55-
56-
vws_client.wait_for_target_processed(target_id=target_id)
57-
58-
with image.open(mode="rb") as my_image_file:
59-
matching_targets = cloud_reco_client.query(image=my_image_file)
60-
61-
assert matching_targets[0].target_id == target_id
62-
63-
Recognition counts
64-
------------------
65-
66-
Vuforia can generate a report of the number of recognitions of each target in a database in a month.
67-
Only the current month and the previous month can be requested.
68-
69-
This needs the ID of the database, which is shown in the Vuforia target manager.
70-
71-
The report is generated in the background, and the URL it is served from expires just under seven days after it is requested.
72-
73-
.. clear-namespace
74-
75-
.. code-block:: python
76-
77-
"""Get the number of recognitions of each target this month."""
78-
79-
import calendar
80-
import datetime as dt
81-
import os
82-
83-
from vws import VWS
84-
85-
server_access_key = os.environ["VWS_SERVER_ACCESS_KEY"]
86-
server_secret_key = os.environ["VWS_SERVER_SECRET_KEY"]
87-
database_id = os.environ["VWS_DATABASE_ID"]
88-
89-
vws_client = VWS(
90-
server_access_key=server_access_key,
91-
server_secret_key=server_secret_key,
92-
database_id=database_id,
28+
client = VuMarkService(
29+
server_access_key=os.environ["VWS_SERVER_ACCESS_KEY"],
30+
server_secret_key=os.environ["VWS_SERVER_SECRET_KEY"],
9331
)
94-
95-
now = dt.datetime.now(tz=dt.UTC)
96-
97-
report_request = vws_client.request_database_reco_counts_report(
98-
year=now.year,
99-
month=calendar.Month(value=now.month),
32+
image = client.generate_vumark_instance(
33+
target_id=os.environ["VUMARK_TARGET_ID"],
34+
instance_id="123",
35+
accept=VuMarkAccept.PNG,
10036
)
101-
102-
report = vws_client.wait_for_reco_counts_report(
103-
presigned_url=report_request.presigned_url,
104-
)
105-
106-
reco_counts_by_target_id = {
107-
item.target_id: item.reco_count for item in report.reco_counts
108-
}
109-
110-
# This database has no targets, so nothing has been recognized.
111-
assert reco_counts_by_target_id == {}
37+
assert image.startswith(b"\x89PNG")
11238
11339
Model Targets
11440
-------------
@@ -199,84 +125,14 @@ Transports are available for `requests`_, `httpx`_ and `HTTPX2`_.
199125

200126
.. clear-namespace
201127
202-
.. code-block:: python
203-
204-
"""List targets using HTTPX2."""
205-
206-
import os
207-
208-
from vws import VWS
209-
from vws.transports import HTTPX2Transport
210-
211-
server_access_key = os.environ["VWS_SERVER_ACCESS_KEY"]
212-
server_secret_key = os.environ["VWS_SERVER_SECRET_KEY"]
213-
214-
vws_client = VWS(
215-
server_access_key=server_access_key,
216-
server_secret_key=server_secret_key,
217-
transport=HTTPX2Transport(),
218-
)
219-
220-
# This database has no targets.
221-
assert len(vws_client.list_targets()) == 0
222-
223128
.. _requests: https://pypi.org/project/requests/
224129
.. _httpx: https://pypi.org/project/httpx/
225130
.. _HTTPX2: https://httpx2.pydantic.dev/
226131

227132
Testing
228133
-------
229134

230-
To write unit tests for code which uses this library, without using your Vuforia quota, you can use the `VWS Python Mock`_ tool:
231-
232-
.. code-block:: console
233-
234-
$ pip install vws-python-mock
235-
236-
.. clear-namespace
237-
238-
.. code-block:: python
239-
240-
"""Add a target to VWS and then query it."""
241-
242-
import pathlib
243-
244-
from mock_vws import MockVWS
245-
from mock_vws.database import CloudDatabase
246-
247-
from vws import VWS, CloudRecoService
248-
249-
with MockVWS() as mock:
250-
database = CloudDatabase()
251-
mock.add_cloud_database(cloud_database=database)
252-
vws_client = VWS(
253-
server_access_key=database.server_access_key,
254-
server_secret_key=database.server_secret_key,
255-
)
256-
cloud_reco_client = CloudRecoService(
257-
client_access_key=database.client_access_key,
258-
client_secret_key=database.client_secret_key,
259-
)
260-
261-
image = pathlib.Path("high_quality_image.jpg")
262-
with image.open(mode="rb") as my_image_file:
263-
target_id = vws_client.add_target(
264-
name="example_image_name",
265-
width=1,
266-
image=my_image_file,
267-
application_metadata=None,
268-
active_flag=True,
269-
)
270-
271-
vws_client.wait_for_target_processed(target_id=target_id)
272-
matching_targets = cloud_reco_client.query(image=my_image_file)
273-
274-
assert matching_targets[0].target_id == target_id
275-
276-
There are some differences between the mock and the real Vuforia.
277-
See https://vws-python.github.io/vws-python-mock/differences-to-vws for details.
278-
279-
.. _VWS Python Mock: https://github.com/VWS-Python/vws-python-mock
135+
Use `VWS Python Mock <https://github.com/VWS-Python/vws-python-mock>`_ to test Model Target and VuMark clients without calling Vuforia.
280136

281137
Reference
282138
---------

‎newsfragments/3328.change.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove Cloud Image Recognition, cloud image target management, recognition reports, and their synchronous/asynchronous public clients.
2+
`ModelTargetService`, `AsyncModelTargetService`, `VuMarkService`, `AsyncVuMarkService`, and their transports remain supported.
3+
This breaks imports of `VWS`, `AsyncVWS`, `CloudRecoService`, `AsyncCloudRecoService`, and cloud-only models and exceptions.

0 commit comments

Comments
 (0)