Skip to content

Commit

Permalink
openvinotoolkit#2570 :Update config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
LalitSP committed Mar 23, 2024
1 parent 1841201 commit ea823dc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nncf/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing import Optional
from typing import Type

from jsonschema.exceptions import ValidationError as JsonSchemaValidationError
import jsonschema
import jstyleson as json

Expand Down Expand Up @@ -105,14 +106,14 @@ def _is_path_to_algorithm_name(path_parts: List[str]) -> bool:
def validate(loaded_json):
try:
jsonschema.validate(loaded_json, NNCFConfig.schema())
except jsonschema.ValidationError as e:
except JsonSchemaValidationError as e:
logger.error('Invalid NNCF config supplied!')
absolute_path_parts = [str(x) for x in e.absolute_path]
if not NNCFConfig._is_path_to_algorithm_name(absolute_path_parts):
e.message += f"\nRefer to the NNCF config schema documentation at " \
f"{SCHEMA_VISUALIZATION_URL}"
e.schema = "*schema too long for stdout display*"
raise e
raise jsonschema.ValidationError("Additional properties are not allowed ('{}' was unexpected)".format(absolute_path_parts[-1]))

# Need to make the error more algo-specific in case the config was so bad that no
# scheme could be matched
Expand All @@ -125,3 +126,5 @@ def validate(loaded_json):
# Passed a list of dicts
for compression_algo_dict in compression_section:
validate_single_compression_algo_schema(compression_algo_dict, REF_VS_ALGO_SCHEMA)
except Exception as e:
raise e

0 comments on commit ea823dc

Please sign in to comment.