Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# _fallback_exceptions.py
 
 
class ORTModuleFallbackException(Exception):  # noqa: N818
    """Base exception class for fallback
 
    Although it must be specialized for specific scenarios,
    it can also be used for generic exception that require fallback
    """
 
 
class ORTModuleInitException(ORTModuleFallbackException):
    """Trigger fallback for ORTModule initialization related exceptions
 
    This exception is triggered when an incompatible or missing requirements for ORTModule are detected,
    including PyTorch version, missing ORTModule's PyTorch C++ extension binaries, etc.
    """
 
 
class ORTModuleDeviceException(ORTModuleFallbackException):
    """Trigger fallback for device related exceptions
 
    NOTE: This exception is raised during device validation within ORTModule frontend.
    Some device related exceptions can only be detected during PyTorch ONNX exporter execution.
    This exception does not capture these scenarios.
    """
 
 
class ORTModuleIOError(ORTModuleFallbackException):
    """Trigger fallback for I/O related exceptions
 
    NOTE: This exception is raised during I/O validation within ORTModule Frontend.
    Some I/O related exceptions can only be detected during PyTorch ONNX exporter execution.
    This exception does not capture these scenarios.
    """
 
 
class ORTModuleTorchModelException(ORTModuleFallbackException):
    """Trigger fallback for PyTorch modules related exceptions
 
    This exception is raised during model validation within ORTModule frontend and is based on
    checking type(model) over a hardcoded list of incompatible models.
    """
 
 
class ORTModuleONNXModelException(ORTModuleFallbackException):
    """Trigger fallback for ONNX model related exceptions
 
    This exception is raised during model conversion to ONNX and post-processing validation within ORTModule frontend.
    """
 
 
def wrap_exception(
    new_exception: ORTModuleFallbackException, raised_exception: Exception
) -> ORTModuleFallbackException:
    """Wraps `raised_exception` exception as cause for the returned `new_exception` exception"""
 
    exception = None
    try:
        raise new_exception(raised_exception) from raised_exception
    except Exception as e:
        exception = e
    return exception