Skip to content

exposed_trusted_builder

Exposed statistics build.

Functions:

Name Description
exposed_trusted_builder

Build ExposedTrustedObject.

exposed_partial_trusted_builder

Build ExposedTrustedObject from partial.

exposed_trusted_builder(module: str, class_: str, *args: object, **kwargs: object) -> TrustedObjectRequestBody #

Build ExposedTrustedObject.

Source code in src/xpdeep/trainer/exposed_trusted_builder.py
def exposed_trusted_builder(module: str, class_: str, *args: object, **kwargs: object) -> TrustedObjectRequestBody:
    """Build ExposedTrustedObject."""
    trusted_object = ExposedTrustedObject(
        reconstructor="_reconstructor",
        class_=class_,
        module=module,
        state=cast(ExposedStateDict, ExposedStateDict.recursive_parse({"args": args, "kwargs": kwargs})),
    )
    dict_parsed = asdict(trusted_object)
    dict_parsed["state"] = base64.encodebytes(NumpyMsgpackEncoder().encode(dict_parsed["state"])).decode("utf-8")

    NumpyMsgpackDecoder(type=ExposedStateDict).decode(NumpyMsgpackEncoder().encode(trusted_object.state))

    return TrustedObjectRequestBody.from_dict(dict_parsed)

exposed_partial_trusted_builder(module: str, class_: str, *args: object, **kwargs: object) -> TrustedObjectRequestBody #

Build ExposedTrustedObject from partial.

Source code in src/xpdeep/trainer/exposed_trusted_builder.py
def exposed_partial_trusted_builder(
    module: str, class_: str, *args: object, **kwargs: object
) -> TrustedObjectRequestBody:
    """Build ExposedTrustedObject from partial."""
    trusted_object = ExposedTrustedObject(
        reconstructor="partial",
        class_=class_,
        module=module,
        state=cast(ExposedStateDict, ExposedStateDict.recursive_parse({"args": args, "kwargs": kwargs})),
    )
    dict_parsed = asdict(trusted_object)
    dict_parsed["state"] = base64.encodebytes(NumpyMsgpackEncoder().encode(dict_parsed["state"])).decode("utf-8")

    NumpyMsgpackDecoder(type=ExposedStateDict).decode(NumpyMsgpackEncoder().encode(trusted_object.state))

    return TrustedObjectRequestBody.from_dict(dict_parsed)