Skip to content

Commit aa2a24e

Browse files
adamtheturtleclaude
andcommitted
Skip signed Model Target requests against real Vuforia by default
Creating an advanced Model Target dataset with a state-based configuration is a signed request which consumes the Vuforia account's small, shared, non-resettable training allowance. Running these cases against the real Vuforia on every CI run exhausted the allowance and turned every run red with TRAINING_ALLOWANCE_EXCEEDED. Skip them against the real Vuforia by default, add a --verify-model-target-signing option to opt back in, and document why. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent c7beff6 commit aa2a24e

3 files changed

Lines changed: 78 additions & 2 deletions

File tree

docs/source/contributing.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,24 @@ Use the following custom ``pytest`` options to skip some tests:
124124
--skip-docker_build_tests
125125
Skip tests for building Docker images
126126
127+
Verifying signed Model Target requests
128+
--------------------------------------
129+
130+
Creating an advanced Model Target dataset with a state-based configuration is a "signed" request: the real Vuforia signs the trained dataset, and each signing consumes the account's Model Target training allowance.
131+
The allowance is small (roughly 20 signings), it is shared by every CI job and every concurrent run, and it cannot be raised or reset.
132+
Verifying signed requests on every run exhausted the allowance within hours and then made every CI run fail with ``TRAINING_ALLOWANCE_EXCEEDED``.
133+
134+
The signed test cases therefore run against the mock backends on every run, but are skipped against the real Vuforia by default.
135+
To verify them against the real Vuforia, for example after the allowance has recovered, opt in with:
136+
137+
.. code-block:: text
138+
139+
--verify-model-target-signing
140+
Run signed Model Target dataset tests against
141+
the real Vuforia
142+
143+
The equivalent unsigned requests (a standard dataset, or an advanced dataset without a state-based configuration) consume no allowance and are verified against the real Vuforia on every run.
144+
127145
Documentation
128146
-------------
129147

tests/mock_vws/fixtures/vuforia_backends.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,14 @@ class VuforiaBackend(Enum):
371371
}
372372

373373

374+
# Signed Model Target requests (advanced datasets with a state-based
375+
# configuration) consume the Vuforia account's Model Target training
376+
# allowance. The allowance is small, shared across all CI jobs, and
377+
# cannot be raised or reset, so signed requests run against the real
378+
# Vuforia only when this option is given.
379+
VERIFY_MODEL_TARGET_SIGNING_OPTION = "--verify-model-target-signing"
380+
381+
374382
@beartype
375383
def pytest_addoption(parser: pytest.Parser) -> None:
376384
"""
@@ -387,6 +395,18 @@ def pytest_addoption(parser: pytest.Parser) -> None:
387395
help="Skip tests for building Docker images",
388396
)
389397

398+
parser.addoption(
399+
VERIFY_MODEL_TARGET_SIGNING_OPTION,
400+
action="store_true",
401+
default=False,
402+
help=(
403+
"Run signed Model Target dataset tests against the real "
404+
"Vuforia. These consume the account's small, shared, "
405+
"non-resettable Model Target training allowance, so they "
406+
"run against the mock backends only by default."
407+
),
408+
)
409+
390410

391411
@beartype
392412
def pytest_collection_modifyitems(

tests/mock_vws/test_model_target_web_api.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
credentials_for_backend,
3232
get_access_token,
3333
)
34-
from tests.mock_vws.fixtures.vuforia_backends import VuforiaBackend
34+
from tests.mock_vws.fixtures.vuforia_backends import (
35+
VERIFY_MODEL_TARGET_SIGNING_OPTION,
36+
VuforiaBackend,
37+
)
3538
from tests.mock_vws.utils import ModelTargetEndpoint
3639
from tests.mock_vws.utils.assertions import (
3740
assert_model_target_status,
@@ -1595,8 +1598,34 @@ def test_unknown_dataset(
15951598
assert error["target"].startswith("userId:")
15961599

15971600

1601+
# Creating an advanced dataset with a state-based configuration is a
1602+
# "signed" request: the real Vuforia signs the trained dataset, and each
1603+
# signing consumes the account's Model Target training allowance. The
1604+
# allowance is tiny (roughly 20 signings, under ten CI runs' worth), it
1605+
# is shared by every CI job and every concurrent run, and it cannot be
1606+
# raised or reset by us. Verifying this behavior on every run therefore
1607+
# burns the whole allowance within hours and then turns every CI run red
1608+
# with ``TRAINING_ALLOWANCE_EXCEEDED`` - which is exactly what happened
1609+
# when it ran unconditionally. The equivalent unsigned requests (a
1610+
# standard dataset, or an advanced dataset without a state-based
1611+
# configuration) consume nothing and stay verified on every run.
1612+
_SIGNED_REQUEST_SKIP_REASON = (
1613+
"Signed Model Target requests consume the real Vuforia account's "
1614+
"small, shared, non-resettable training allowance, so they are not "
1615+
"verified against the real Vuforia by default. Pass "
1616+
f"{VERIFY_MODEL_TARGET_SIGNING_OPTION} to verify them, for example "
1617+
"after the allowance has recovered. The mock backends always run "
1618+
"this test."
1619+
)
1620+
1621+
15981622
class TestStateBasedDatasets:
1599-
"""Verified fake tests for State-Based Model Targets."""
1623+
"""Verified fake tests for State-Based Model Targets.
1624+
1625+
The advanced (signed) cases are verified against the real Vuforia
1626+
only when ``--verify-model-target-signing`` is given: see
1627+
``_SIGNED_REQUEST_SKIP_REASON``.
1628+
"""
16001629

16011630
@staticmethod
16021631
@pytest.mark.parametrize(
@@ -1621,13 +1650,22 @@ class TestStateBasedDatasets:
16211650
)
16221651
def test_state_based_dataset(
16231652
*,
1653+
request: pytest.FixtureRequest,
16241654
verify_model_target_mock_vuforia: VuforiaBackend,
16251655
dataset_path: str,
16261656
view_updates: dict[str, object],
16271657
) -> None:
16281658
"""State-Based Model Target fields survive a dataset round
16291659
trip.
16301660
"""
1661+
if (
1662+
verify_model_target_mock_vuforia is VuforiaBackend.REAL
1663+
and dataset_path == "/modeltargets/advancedDatasets"
1664+
and not request.config.getoption(
1665+
name=VERIFY_MODEL_TARGET_SIGNING_OPTION,
1666+
)
1667+
):
1668+
pytest.skip(reason=_SIGNED_REQUEST_SKIP_REASON)
16311669
body = {
16321670
**_UNAUTHENTICATED_DATASET_REQUEST,
16331671
"models": [

0 commit comments

Comments
 (0)