MCPcopy Create free account
hub / github.com/PAIR-code/lit / raise_or_log_error

Function raise_or_log_error

lit_nlp/lib/validation.py:41–49  ·  view source on GitHub ↗

Raise (if report_all=False) or log (and return) a validation error.

(
      msg: str, origin: Optional[ValueError] = None
  )

Source from the content-addressed store, hash-verified

39 first_error_origin: Optional[ValueError] = None
40
41 def raise_or_log_error(
42 msg: str, origin: Optional[ValueError] = None
43 ) -> ValueError:
44 """Raise (if report_all=False) or log (and return) a validation error."""
45 if report_all:
46 logging.error(termcolor.colored(msg, 'red'))
47 return ValueError(msg)
48 else:
49 raise ValueError(msg) from origin
50
51 for key, entry in ds.spec().items():
52 if enforce_all_fields_required and not entry.required:

Callers 2

validate_datasetFunction · 0.85
validate_modelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected