nvflare.apis.shareable module

class ReservedHeaderKey[source]

Bases: object

AUDIT_EVENT_ID = '__audit_event_id__'
CONTENT_TYPE = '__content_type__'
COOKIE_JAR = '__cookie_jar__'
ERROR = '__error__'
HEADERS = '__headers__'
PEER_PROPS = '__peer_props__'
RC = '__rc__'
REPLY_IS_LATE = '__reply_is_late__'
TASK_ID = '__task_id__'
TASK_NAME = '__task_name__'
TASK_OPERATOR = '__task_operator__'
TOPIC = '__topic__'
WORKFLOW = '__workflow__'
class Shareable[source]

Bases: dict

The information communicated between server and client.

Shareable is just a dict that can have any keys and values, defined by developers and users. It is recommended that keys are strings. Values must be serializable.

Init the Shareable.

Add a cookie that is to be sent to the client and echoed back in response.

This method is intended to be called by the Server side.

Parameters:
  • name – the name of the cookie

  • data – the data of the cookie, which must be serializable

classmethod from_bytes(data: bytes)[source]

Convert the data bytes into Model object.

Parameters:

data – a bytes object

Returns:

an object loaded by FOBS from data

get_header(key: str, default=None)[source]
get_peer_prop(key: str, default)[source]
get_peer_props()[source]
get_return_code(default='OK')[source]
set_header(key: str, value)[source]
set_peer_props(props: dict)[source]
set_return_code(rc)[source]
to_bytes() bytes[source]

Serialize the Model object into bytes.

Returns:

object serialized in bytes.

make_copy(source: Shareable) Shareable[source]

Make a copy from the source. The content (non-headers) will be kept intact. Headers will be deep-copied into the new instance.

make_reply(rc, headers=None) Shareable[source]