Federation API¶
Low level api¶
Attributes¶
__all__ = ['FederationABC']
module-attribute
¶
Classes¶
FederationABC
¶
federation, get or remote objects and tables
Attributes¶
session_id: str
property
abstractmethod
¶
Functions¶
get(name, tag, parties, gc)
abstractmethod
¶
get objects/tables from parties
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
name of transfer variable |
required |
tag |
str
|
tag to distinguish each transfer |
required |
parties |
typing.List[Party]
|
parties to get objects/tables from |
required |
gc |
GarbageCollectionABC
|
used to do some clean jobs |
required |
Returns:
Type | Description |
---|---|
list
|
a list of object or a list of table get from parties with same order of |
Source code in python/fate_arch/abc/_federation.py
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 |
|
remote(v, name, tag, parties, gc)
abstractmethod
¶
remote object/table to parties
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
object/table to remote |
required | |
name |
str
|
name of transfer variable |
required |
tag |
str
|
tag to distinguish each transfer |
required |
parties |
typing.List[Party]
|
parties to remote object/table to |
required |
gc |
GarbageCollectionABC
|
used to do some clean jobs |
required |
Returns:
Type | Description |
---|---|
Notes
|
Source code in python/fate_arch/abc/_federation.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
destroy(parties)
abstractmethod
¶
destroy federation from parties
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parties |
parties to get objects/tables from |
required |
Returns:
Type | Description |
---|---|
None
|
Source code in python/fate_arch/abc/_federation.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
user api¶
remoting or getting an object(table) from other parties is quite easy using apis provided in Variable
.
First to create an instance of BaseTransferVariable, which is simply a collection of Variables:
from federatedml.transfer_variable.transfer_class import secure_add_example_transfer_variable
variable = secure_add_example_transfer_variable.SecureAddExampleTransferVariable()
Then remote or get object(table) by variable provided by this instance:
# remote
variable.guest_share.remote("from guest")
# get
variable.guest_share.get()
Attributes¶
__all__ = ['Variable', 'BaseTransferVariables']
module-attribute
¶
LOGGER = getLogger()
module-attribute
¶
Classes¶
FederationTagNamespace
¶
Bases: object
Attributes¶
__namespace = 'default'
instance-attribute
class-attribute
¶
Functions¶
set_namespace(namespace)
classmethod
¶
Source code in python/fate_arch/federation/transfer_variable.py
33 34 35 |
|
generate_tag(*suffix)
classmethod
¶
Source code in python/fate_arch/federation/transfer_variable.py
37 38 39 40 |
|
Variable(name, src, dst)
¶
Bases: object
variable to distinguish federation by name
Source code in python/fate_arch/federation/transfer_variable.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
Attributes¶
__instances: typing.MutableMapping[str, Variable] = {}
instance-attribute
class-attribute
¶
Functions¶
get_or_create(name, create_func)
classmethod
¶
Source code in python/fate_arch/federation/transfer_variable.py
50 51 52 53 54 55 56 57 |
|
__copy__()
¶
Source code in python/fate_arch/federation/transfer_variable.py
86 87 |
|
__deepcopy__(memo)
¶
Source code in python/fate_arch/federation/transfer_variable.py
90 91 |
|
set_preserve_num(n)
¶
Source code in python/fate_arch/federation/transfer_variable.py
93 94 95 96 |
|
disable_auto_clean()
¶
Source code in python/fate_arch/federation/transfer_variable.py
98 99 100 101 |
|
clean()
¶
Source code in python/fate_arch/federation/transfer_variable.py
103 104 105 |
|
remote_parties(obj, parties, suffix=tuple())
¶
remote object to specified parties
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
object or table to remote |
required | |
parties |
Union[typing.List[Party], Party]
|
parties to remote object/table to |
required |
suffix |
Union[typing.Any, typing.Tuple]
|
suffix used to distinguish federation with in variable |
tuple()
|
Returns:
Type | Description |
---|---|
None
|
Source code in python/fate_arch/federation/transfer_variable.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
get_parties(parties, suffix=tuple())
¶
get objects/tables from specified parties
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parties |
Union[typing.List[Party], Party]
|
parties to remote object/table to |
required |
suffix |
Union[typing.Any, typing.Tuple]
|
suffix used to distinguish federation with in variable |
tuple()
|
Returns:
Type | Description |
---|---|
list
|
a list of objects/tables get from parties with same order of |
Source code in python/fate_arch/federation/transfer_variable.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
remote(obj, role=None, idx=-1, suffix=tuple())
¶
send obj to other parties.
Args: obj: object to be sent role: role of parties to sent to, use one of ['Host', 'Guest', 'Arbiter', None]. The default is None, means sent values to parties regardless their party role idx: id of party to sent to. The default is -1, which means sent values to parties regardless their party id suffix: additional tag suffix, the default is tuple()
Source code in python/fate_arch/federation/transfer_variable.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
get(idx=-1, role=None, suffix=tuple())
¶
get obj from other parties.
Args: idx: id of party to get from. The default is -1, which means get values from parties regardless their party id suffix: additional tag suffix, the default is tuple()
Returns: object or list of object
Source code in python/fate_arch/federation/transfer_variable.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
BaseTransferVariables(*args)
¶
Bases: object
Source code in python/fate_arch/federation/transfer_variable.py
284 285 |
|
Functions¶
__copy__()
¶
Source code in python/fate_arch/federation/transfer_variable.py
287 288 |
|
__deepcopy__(memo)
¶
Source code in python/fate_arch/federation/transfer_variable.py
290 291 |
|
set_flowid(flowid)
staticmethod
¶
set global namespace for federations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flowid |
namespace |
required |
Returns:
Type | Description |
---|---|
None
|
Source code in python/fate_arch/federation/transfer_variable.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
all_parties()
staticmethod
¶
get all parties
Returns:
Type | Description |
---|---|
list
|
list of parties |
Source code in python/fate_arch/federation/transfer_variable.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
|
local_party()
staticmethod
¶
indicate local party
Returns:
Type | Description |
---|---|
Party
|
party this program running on |
Source code in python/fate_arch/federation/transfer_variable.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|