-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5383 from FederatedAI/feature-2.0.0-rc-add-contex…
…t-create-helper feature 2.0.0 rc add context create helper
- Loading branch information
Showing
5 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from typing import Tuple, List | ||
|
||
from fate.arch.computing import ComputingBuilder, ComputingEngine | ||
from fate.arch.context import Context | ||
from fate.arch.federation import FederationBuilder, FederationType | ||
|
||
|
||
def create_context( | ||
local_party: Tuple[str, str], | ||
parties: List[Tuple[str, str]], | ||
federation_session_id, | ||
federation_engine=FederationType.STANDALONE, | ||
federation_conf: dict = None, | ||
computing_session_id=None, | ||
computing_engine=ComputingEngine.STANDALONE, | ||
computing_conf=None, | ||
): | ||
if federation_conf is None: | ||
federation_conf = {} | ||
if computing_conf is None: | ||
computing_conf = {} | ||
if ComputingEngine.STANDALONE == computing_engine: | ||
if "computing.standalone.data_dir" not in computing_conf: | ||
computing_conf["computing.standalone.data_dir"] = "/tmp" | ||
if computing_session_id is None: | ||
computing_session_id = f"{federation_session_id}_{local_party[0]}_{local_party[1]}" | ||
computing_session = ComputingBuilder(computing_session_id=computing_session_id).build( | ||
computing_engine, computing_conf | ||
) | ||
federation_session = FederationBuilder( | ||
federation_id=federation_session_id, | ||
party=local_party, | ||
parties=parties, | ||
).build(computing_session, federation_engine, federation_conf) | ||
return Context(computing=computing_session, federation=federation_session) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters