mithril-security / blindai

Confidential AI deployment with secure enclaves :lock:
https://www.mithrilsecurity.io/
Apache License 2.0
500 stars 35 forks source link

Proper docstring in client API and simulation mode GRPC ambiguity #84

Closed kbamponsem closed 2 years ago

kbamponsem commented 2 years ago

Description

This PR fixes both the unclear docstrings in the client API and the simulation mode error ambiguity in the client and server.


            model (str): Path to Onnx model file.
            tensor_inputs (Union[Tuple[List[int], ModelDatumType], List[Tuple[List[int], ModelDatumType]]): The list of input fact and datum types for each input grouped together in lists, describing the different inputs of the model.
            tensor_outputs (Union[ModelDatumType, List[ModelDatumType]): The list of datum types describing the different output types of the model. Defaults to ModelDatumType.F32
            shape (Tuple, optional): The shape of the model input. Defaults to None.
            dtype (ModelDatumType, optional): The type of the model input data (f32 by default). Defaults to ModelDatumType.F32.
            dtype_out (ModelDatumType, optional): The type of the model output data (f32 by default). Defaults to ModelDatumType.F32.
            sign (bool, optional): Get signed responses from the server or not. Defaults to False.
            model_name (Optional[str], optional): Name of the model.

def check_rpc_exception(rpc_error): if rpc_error.code() == grpc.StatusCode.CANCELLED: return f"Cancelled GRPC call: code={rpc_error.code()} message={rpc_error.details()}"

elif rpc_error.code() == grpc.StatusCode.UNAVAILABLE:
    return f"Failed to connect to GRPC server: code={rpc_error.code()} message={rpc_error.details()}"

elif rpc_error.code() == grpc.StatusCode.UNIMPLEMENTED:
    return f"Incompatible client/server versions, code={rpc_error.code()} message={rpc_error.details()}"

elif rpc_error.code() == grpc.StatusCode.FAILED_PRECONDITION:
    return f"Attestation is not available. Running in Simulation Mode, code={rpc_error.code()} message={rpc_error.details()}"
else:
    return (
        f"Received RPC error: code={rpc_error.code()} message={rpc_error.details()}"
    )
- On the server side:
```rust
if cfg!(SGX_MODE = "SW") {
            return Err(Status::failed_precondition(
                "Attestation is not available. Running in Simulation Mode",
            ));
        }

Related Issue

This project accepts pull requests related to open issues. If suggesting a new feature or change, please discuss it in an issue first. If fixing a bug, there should be an issue describing it with steps to reproduce. Please link to the issue here.

Type of change

The types of changes must be deduced from the labels of the related issues. Please consider providing these further details.

How Has This Been Tested?

All the client unit tests work perfectly, and the end-to-end tests, also work.

Checklist: