Skip to content

Commit f0cbce1

Browse files
committed
Rename CatalogValidator to CatalogSchemaValidator
1 parent cc30037 commit f0cbce1

5 files changed

Lines changed: 22 additions & 21 deletions

File tree

agent_sdks/python/a2ui_core/src/a2ui/core/validating/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
validate_recursion_and_paths,
2020
get_component_references,
2121
)
22-
from .catalog_validator import CatalogValidator
22+
from .catalog_schema_validator import CatalogSchemaValidator
2323

2424
__all__ = [
2525
"A2uiValidator",
@@ -29,5 +29,5 @@
2929
"validate_component_integrity",
3030
"validate_recursion_and_paths",
3131
"get_component_references",
32-
"CatalogValidator",
32+
"CatalogSchemaValidator",
3333
]

agent_sdks/python/a2ui_core/src/a2ui/core/validating/catalog_validator.py renamed to agent_sdks/python/a2ui_core/src/a2ui/core/validating/catalog_schema_validator.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from referencing.jsonschema import DRAFT202012
2020

2121
from ..catalog import Catalog, ComponentApi, ModelComponentApi
22+
from ..catalog.catalog import TComponent, TFunction
2223
from ..schema.common_types import (
2324
ComponentReference,
2425
ListReference,
@@ -36,8 +37,8 @@ def _schema_url(spec_version: str, file_name: str) -> str:
3637
return f"{SPEC_BASE_URL}/{ver.replace('.', '_')}/{file_name}"
3738

3839

39-
class CatalogValidator:
40-
"""Consolidated Catalog Validator for A2UI catalogs using jsonschema engine."""
40+
class CatalogSchemaValidator:
41+
"""Consolidated Catalog Schema Validator for A2UI catalogs using jsonschema engine."""
4142

4243
def __init__(self, catalog: Catalog[TComponent, TFunction]):
4344
self.catalog = catalog
@@ -339,8 +340,8 @@ def extract_ref_fields(self) -> Dict[str, Tuple[Set[str], Set[str]]]:
339340
return extract_ref_fields(self.catalog)
340341

341342
@classmethod
342-
def from_catalog(cls, catalog: Any) -> "CatalogValidator":
343-
if isinstance(catalog, CatalogValidator):
343+
def from_catalog(cls, catalog: Any) -> "CatalogSchemaValidator":
344+
if isinstance(catalog, CatalogSchemaValidator):
344345
return catalog
345346
return cls(catalog)
346347

agent_sdks/python/a2ui_core/src/a2ui/core/validating/validator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
validate_recursion_and_paths,
3232
)
3333
from .topology_analyzer import analyze_topology
34-
from .catalog_validator import CatalogValidator
34+
from .catalog_schema_validator import CatalogSchemaValidator
3535

3636

3737
class A2uiValidatorError(ValueError):
@@ -116,7 +116,7 @@ def _format_validation_errors(
116116

117117
def validate_components(
118118
self,
119-
catalog_validator: CatalogValidator,
119+
schema_validator: CatalogSchemaValidator,
120120
components: List[Dict[str, Any]],
121121
config: ValidationConfig = ValidationConfig(),
122122
) -> None:
@@ -126,12 +126,12 @@ def validate_components(
126126
# invalid component and collect all schema validation errors across the payload.
127127
for c in components:
128128
try:
129-
catalog_validator.validate_components([c])
129+
schema_validator.validate_components([c])
130130
except Exception as ce:
131131
errors.append(ce)
132132
if not errors:
133133
try:
134-
ref_fields = catalog_validator.extract_ref_fields()
134+
ref_fields = schema_validator.extract_ref_fields()
135135
validate_component_integrity(
136136
components,
137137
ref_fields,
@@ -150,7 +150,7 @@ def validate_components(
150150

151151
def validate(
152152
self,
153-
catalog_validator: CatalogValidator,
153+
schema_validator: CatalogSchemaValidator,
154154
a2ui_payload: Union[Dict[str, Any], List[Any]],
155155
config: Optional[ValidationConfig] = None,
156156
) -> None:
@@ -173,14 +173,14 @@ def validate(
173173
if MSG_TYPE_CREATE_SURFACE in msg:
174174
theme = msg[MSG_TYPE_CREATE_SURFACE].get(THEME_KEY)
175175
if theme:
176-
catalog_validator.validate_theme(theme)
176+
schema_validator.validate_theme(theme)
177177
elif MSG_TYPE_UPDATE_COMPONENTS in msg:
178178
components = msg[MSG_TYPE_UPDATE_COMPONENTS].get(
179179
CATALOG_COMPONENTS_KEY
180180
)
181181
if isinstance(components, list):
182182
self.validate_components(
183-
catalog_validator,
183+
schema_validator,
184184
components,
185185
config=config,
186186
)

agent_sdks/python/a2ui_core/tests/test_catalog.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
ModelComponentApi,
2222
FunctionImplementation,
2323
)
24-
from a2ui.core.validating import CatalogValidator
24+
from a2ui.core.validating import CatalogSchemaValidator
2525
from a2ui.core.basic_catalog import BasicCatalog
2626
from a2ui.core.schema.common_types import ComponentId
2727
from a2ui.core.schema.constants import SPEC_VERSION
2828

2929

30-
def _val(catalog: Catalog[Any, Any]) -> CatalogValidator:
31-
return CatalogValidator.from_catalog(catalog)
30+
def _val(catalog: Catalog[Any, Any]) -> CatalogSchemaValidator:
31+
return CatalogSchemaValidator.from_catalog(catalog)
3232

3333

3434
# ==============================================================================
@@ -867,7 +867,7 @@ class ModelCompA(BaseModel):
867867
],
868868
)
869869

870-
validator = CatalogValidator(catalog)
870+
validator = CatalogSchemaValidator(catalog)
871871

872872
# 1. Validate payload conforming to ModelComponentApi
873873
validator.validate_components(

agent_sdks/python/a2ui_core/tests/test_validating.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
validate_recursion_and_paths,
2525
get_component_references,
2626
ValidationConfig,
27-
CatalogValidator,
27+
CatalogSchemaValidator,
2828
)
2929
from a2ui.core.basic_catalog import BasicCatalog
3030

@@ -267,7 +267,7 @@ def test_a2ui_validator_validate_valid_payload():
267267
},
268268
]
269269

270-
validator.validate(CatalogValidator.from_catalog(catalog), messages)
270+
validator.validate(CatalogSchemaValidator.from_catalog(catalog), messages)
271271

272272

273273
def test_a2ui_validator_validate_components_error():
@@ -290,7 +290,7 @@ def test_a2ui_validator_validate_components_error():
290290
]
291291

292292
with pytest.raises(A2uiValidatorError):
293-
validator.validate(CatalogValidator.from_catalog(catalog), messages)
293+
validator.validate(CatalogSchemaValidator.from_catalog(catalog), messages)
294294

295295

296296
def test_topology_cyclomatic_orphans_coverage():
@@ -421,7 +421,7 @@ def test_validator_aggregated_pydantic_error_formatting():
421421
def test_validator_config_parameter():
422422
# Verify that ValidationConfig is respected during validation
423423

424-
catalog = CatalogValidator.from_catalog(BasicCatalog())
424+
catalog = CatalogSchemaValidator.from_catalog(BasicCatalog())
425425
validator = A2uiValidator()
426426
strict_config = ValidationConfig(
427427
allow_orphan_components=False, allow_dangling_references=False

0 commit comments

Comments
 (0)