Closed kevin-bates closed 2 years ago
Looks like the Windows 3.6 platform is no longer available for CI. I can remove 3.6 from the CI matrix, but that feels better suited for another PR.
Thank you @blink1073! It will be great to take advantage of these changes in Jupyter Server.
This pull request stems from an issue discovered during Jupyter Server performance analysis in which it was learned that the server is validating notebooks twice (and on both read and write operations). The crux of the issue is that both methods do not give the caller information regarding the validation status of their content - so they must explicitly validate a second time. This appears to have been the case for the last 7 to 8 years (since the code resided in notebook). I suspect this is based on decisions at the time, but this pull request attempts to rectify this in a (hopefully) acceptable manner. Since the elimination of the redundant validation can improve performance by nearly 50%, this seems like an opportunity we should not ignore.
Because so many years have passed, I believe there are at least two backward-compatibility concerns that lead to this particular resolution.
validate()
method, to capture the exception and produce an application-friendly error message when validation issues are encountered.This change adds an optional dictionary-valued parameter (
capture_validation_error
) that applications can pass to capture theValidationError
instance for use by the calling application. If the parameter is non-None and a dictionary instance, a validation error will be added into the dictionary under the key'ValidationError'
while the corresponding value will contain theValidationError
instance. This would allow applications that make an additional call tovalidate()
to remove the second call since they have both their content (on reads) and theValidationError
instance (when validation issues are present) they can use to make decisions.Alternative approaches
ValidationError
when it occurs, which also allows the application to produce a friendly message, but will prevent the return of content (on reads) and persistence of content (on writes) - that is assumed behavior today.There may be other solutions, but I think we should do something as this is the kind of low-hanging fruit that performance-sensitive folks live for. :smile:
cc: @goanpeca, @mlucool