forked from NVIDIA/NVFlare
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update github actions (NVIDIA#2450) * Fix premerge (NVIDIA#2467) * Fix issues on hello-world TF2 notebook * Fix tf integration test (NVIDIA#2504) * Add client api integration tests --------- Co-authored-by: Isaac Yang <[email protected]> Co-authored-by: Sean Yang <[email protected]>
- Loading branch information
1 parent
d4afbee
commit 2eed407
Showing
68 changed files
with
3,645 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ jobs: | |
markdown-link-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/checkout@v4 | ||
- uses: gaurav-nelson/[email protected] | ||
with: | ||
max-depth: -1 | ||
|
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
43 changes: 43 additions & 0 deletions
43
tests/integration_test/data/jobs/np_loop/app_client/config/config_fed_client.conf
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,43 @@ | ||
{ | ||
format_version = 2 | ||
app_script = "train_loop.py" | ||
app_config = "" | ||
executors = [ | ||
{ | ||
tasks = [ | ||
"train" | ||
] | ||
executor { | ||
path = "nvflare.app_common.executors.client_api_launcher_executor.ClientAPILauncherExecutor" | ||
args { | ||
launcher_id = "launcher" | ||
pipe_id = "pipe" | ||
heartbeat_timeout = 60 | ||
params_exchange_format = "numpy" | ||
params_transfer_type = "FULL" | ||
train_with_evaluation = true | ||
} | ||
} | ||
} | ||
] | ||
task_data_filters = [] | ||
task_result_filters = [] | ||
components = [ | ||
{ | ||
id = "launcher" | ||
path = "nvflare.app_common.launchers.subprocess_launcher.SubprocessLauncher" | ||
args { | ||
script = "python3 custom/{app_script} {app_config} " | ||
launch_once = true | ||
} | ||
} | ||
{ | ||
id = "pipe" | ||
path = "nvflare.fuel.utils.pipe.file_pipe.FilePipe" | ||
args { | ||
mode = "PASSIVE" | ||
root_path = "{WORKSPACE}/{JOB_ID}/{SITE_NAME}" | ||
} | ||
} | ||
] | ||
} |
60 changes: 60 additions & 0 deletions
60
tests/integration_test/data/jobs/np_loop/app_client/custom/train_diff.py
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,60 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import copy | ||
|
||
import nvflare.client as flare | ||
|
||
|
||
def train(input_arr): | ||
output_arr = copy.deepcopy(input_arr) | ||
# mock training with plus 1 | ||
return output_arr + 1 | ||
|
||
|
||
def evaluate(input_arr): | ||
# mock evaluation metrics | ||
return 100 | ||
|
||
|
||
def main(): | ||
# initializes NVFlare interface | ||
flare.init() | ||
|
||
# get model from NVFlare | ||
input_model = flare.receive() | ||
print(f"received weights is: {input_model.params}") | ||
|
||
# get system information | ||
sys_info = flare.system_info() | ||
print(f"system info is: {sys_info}") | ||
|
||
input_numpy_array = input_model.params["numpy_key"] | ||
|
||
# training | ||
output_numpy_array = train(input_numpy_array) | ||
|
||
# evaluation | ||
metrics = evaluate(input_numpy_array) | ||
|
||
# calculate difference here | ||
diff = output_numpy_array - input_numpy_array | ||
|
||
# send back the model difference | ||
print(f"send back: {diff}") | ||
flare.send(flare.FLModel(params={"numpy_key": diff}, params_type="DIFF", metrics={"accuracy": metrics})) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
59 changes: 59 additions & 0 deletions
59
tests/integration_test/data/jobs/np_loop/app_client/custom/train_full.py
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,59 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import copy | ||
|
||
import nvflare.client as flare | ||
|
||
|
||
def train(input_arr): | ||
output_arr = copy.deepcopy(input_arr) | ||
# mock training with plus 1 | ||
return output_arr + 1 | ||
|
||
|
||
def evaluate(input_arr): | ||
# mock evaluation metrics | ||
return 100 | ||
|
||
|
||
def main(): | ||
# initializes NVFlare interface | ||
flare.init() | ||
|
||
# get model from NVFlare | ||
input_model = flare.receive() | ||
print(f"received weights is: {input_model.params}") | ||
|
||
# get system information | ||
sys_info = flare.system_info() | ||
print(f"system info is: {sys_info}") | ||
|
||
input_numpy_array = input_model.params["numpy_key"] | ||
|
||
# training | ||
output_numpy_array = train(input_numpy_array) | ||
|
||
# evaluation | ||
metrics = evaluate(input_numpy_array) | ||
|
||
# send back the model | ||
print(f"send back: {output_numpy_array}") | ||
flare.send( | ||
flare.FLModel(params={"numpy_key": output_numpy_array}, params_type="FULL", metrics={"accuracy": metrics}) | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.